当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableSet.contains方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableSet.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSet.contains方法的具体用法?Java ImmutableSet.contains怎么用?Java ImmutableSet.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableSet的用法示例。


在下文中一共展示了ImmutableSet.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rewriteIdentifiers

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private static void rewriteIdentifiers(N4JSGrammarAccess ga,
		ImmutableMap.Builder<AbstractElement, Integer> builder) {
	ImmutableSet<AbstractRule> identifierRules = ImmutableSet.of(
			ga.getBindingIdentifierRule(),
			ga.getIdentifierNameRule(),
			ga.getIDENTIFIERRule());
	for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
		for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
			if (obj instanceof Assignment) {
				Assignment assignment = (Assignment) obj;
				AbstractElement terminal = assignment.getTerminal();
				int type = InternalN4JSParser.RULE_IDENTIFIER;
				if (terminal instanceof CrossReference) {
					terminal = ((CrossReference) terminal).getTerminal();
					type = IDENTIFIER_REF_TOKEN;
				}
				if (terminal instanceof RuleCall) {
					AbstractRule calledRule = ((RuleCall) terminal).getRule();
					if (identifierRules.contains(calledRule)) {
						builder.put(assignment, type);
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:TokenTypeRewriter.java

示例2: resolveStatesToBeWritten

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted.
 * Each index state that should be written to disk will be returned. This is only run for data only nodes.
 * It will return only the states for indices that actually have a shard allocated on the current node.
 *
 * @param previouslyWrittenIndices    A list of indices for which the state was already written before
 * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written
 * @param previousMetaData            The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now
 * @param newMetaData                 The new metadata
 * @return iterable over all indices states that should be written to disk
 */
public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(ImmutableSet<String> previouslyWrittenIndices, Set<String> potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) {
    List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>();
    for (String index : potentiallyUnwrittenIndices) {
        IndexMetaData newIndexMetaData = newMetaData.index(index);
        IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index);
        String writeReason = null;
        if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) {
            writeReason = "freshly created";
        } else if (previousIndexMetaData.getVersion() != newIndexMetaData.getVersion()) {
            writeReason = "version changed from [" + previousIndexMetaData.getVersion() + "] to [" + newIndexMetaData.getVersion() + "]";
        }
        if (writeReason != null) {
            indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason));
        }
    }
    return indicesToWrite;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:GatewayMetaState.java

示例3: getRelevantIndicesOnDataOnlyNode

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public static Set<String> getRelevantIndicesOnDataOnlyNode(ClusterState state, ClusterState previousState, ImmutableSet<String> previouslyWrittenIndices) {
    RoutingNode newRoutingNode = state.getRoutingNodes().node(state.nodes().localNodeId());
    if (newRoutingNode == null) {
        throw new IllegalStateException("cluster state does not contain this node - cannot write index meta state");
    }
    Set<String> indices = new HashSet<>();
    for (ShardRouting routing : newRoutingNode) {
        indices.add(routing.index());
    }
    // we have to check the meta data also: closed indices will not appear in the routing table, but we must still write the state if we have it written on disk previously
    for (IndexMetaData indexMetaData : state.metaData()) {
        boolean isOrWasClosed = indexMetaData.getState().equals(IndexMetaData.State.CLOSE);
        // if the index is open we might still have to write the state if it just transitioned from closed to open
        // so we have to check for that as well.
        IndexMetaData previousMetaData = previousState.metaData().getIndices().get(indexMetaData.getIndex());
        if (previousMetaData != null) {
            isOrWasClosed = isOrWasClosed || previousMetaData.getState().equals(IndexMetaData.State.CLOSE);
        }
        if (previouslyWrittenIndices.contains(indexMetaData.getIndex()) && isOrWasClosed) {
            indices.add(indexMetaData.getIndex());
        }
    }
    return indices;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:GatewayMetaState.java

示例4: filter

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private static ImmutableList<Node> filter(ImmutableList<Node> nodeTree, ImmutableSet<String> knownNames, ImmutableSet<String> src, int level) {
	ImmutableList.Builder<Node> builder = ImmutableList.builder();

	for (String current : src) {
		if (!knownNames.contains(current)) {
			if (level==0) {
				builder.add(Node.builder().name(current).build());
			}
		} else {
			Optional<Node> matchingNode = nodeTree.stream()
				.filter(n -> n.name().equals(current))
				.findAny();
			matchingNode.ifPresent(node -> {
				builder.add(Node.builder()
						.name(current)
						.addAllChildren(filter(node.children(), knownNames, src, level+1))
						.build());
			});
		}
	}
	return builder.build();
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:23,代码来源:Tree.java

示例5: modifiableAsJavaBean

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Test
public void modifiableAsJavaBean() throws Exception {
  ImmutableSet<String> rwProperties =
      ImmutableSet.of("primary", "id", "description", "names", "options", "extra");

  FluentIterable<PropertyDescriptor> propertyDescriptors =
      FluentIterable.of(
          Introspector.getBeanInfo(ModifiableBeanFriendly.class)
              .getPropertyDescriptors());

  check(propertyDescriptors.transform(p -> p.getName()).toSet().containsAll(rwProperties));

  for (PropertyDescriptor pd : propertyDescriptors) {
    check(pd.getReadMethod()).notNull();
    if (rwProperties.contains(pd.getName())) {
      check(pd.getWriteMethod()).notNull();
    }
  }

  ModifiableBeanFriendly bean = new ModifiableBeanFriendly();
  bean.setPrimary(true);
  bean.setDescription("description");
  bean.setId(1000);
  bean.setNames(ImmutableList.of("name"));
  bean.addNames("name2");
  bean.putOptions("foo", "bar");

  // This bean can become immutable.
  BeanFriendly immutableBean = bean.toImmutable();
  check(immutableBean.isPrimary());
  check(immutableBean.getDescription()).is("description");
  check(immutableBean.getId()).is(1000);
  check(immutableBean.getNames()).isOf("name", "name2");
  check(immutableBean.getOptions()).is(ImmutableMap.of("foo", "bar"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:BeanFriendlyTest.java

示例6: getTokenType

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private Integer getTokenType(String text, ImmutableSet<String> set, int type, Integer refinedType) {
	if (refinedType != null) {
		if (set.contains(text)) {
			throw new RuntimeException("duplicate keyword declaration: " + text);
		}
		return refinedType;
	}
	if (set.contains(text)) {
		return type;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:TokenTypeRewriter.java

示例7: computeResponseTransformation

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Override
public ResponseMapping computeResponseTransformation(final AnswerKey answerKey) {
  final ImmutableSet<TypeRoleFillerRealis> bannedResponseSignatures =
      computeBannedResponseSignatures(answerKey);

  final ImmutableSet.Builder<Response> toDelete = ImmutableSet.builder();
  for (final Response response : answerKey.allResponses()) {
    if (bannedResponseSignatures.contains(responseSignature(response))) {
      toDelete.add(response);
    }
  }

  return ResponseMapping.create(ImmutableMap.<Response, Response>of(), toDelete.build());
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:15,代码来源:OnlyMostSpecificTemporal.java

示例8: upperToHttpHeaderName

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private static String upperToHttpHeaderName(String constantName,
    ImmutableBiMap<String, String> specialCases, ImmutableSet<String> uppercaseAcronyms) {
  if (specialCases.containsKey(constantName)) {
    return specialCases.get(constantName);
  }
  List<String> parts = Lists.newArrayList();
  for (String part : SPLITTER.split(constantName)) {
    if (!uppercaseAcronyms.contains(part)) {
      part = part.charAt(0) + Ascii.toLowerCase(part.substring(1));
    }
    parts.add(part);
  }
  return JOINER.join(parts);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:HttpHeadersTest.java

示例9: findIdentifier

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Returns the index of the first place where one of the given identifiers occurs, or {@code
 * Optional.absent()} if there is none.
 *
 * @param start       the index to start looking at
 * @param identifiers the identifiers to look for
 */
private Optional<Integer> findIdentifier(int start, ImmutableSet<String> identifiers) {
    for (int i = start; i < toks.size(); i++) {
        if (isIdentifierToken(i)) {
            String id = tokenAt(i);
            if (identifiers.contains(id)) {
                return Optional.of(i);
            }
        }
    }
    return Optional.absent();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:ImportOrderer.java

示例10: testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public void testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives() {
  int numInsertions = 1000000;
  BloomFilter<String> bf = BloomFilter.create(
      Funnels.unencodedCharsFunnel(), numInsertions, 0.03,
      BloomFilterStrategies.MURMUR128_MITZ_32);

  // Insert "numInsertions" even numbers into the BF.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    bf.put(Integer.toString(i));
  }

  // Assert that the BF "might" have all of the even numbers.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    assertTrue(bf.mightContain(Integer.toString(i)));
  }

  // Now we check for known false positives using a set of known false positives.
  // (These are all of the false positives under 900.)
  ImmutableSet<Integer> falsePositives = ImmutableSet.of(
      49, 51, 59, 163, 199, 321, 325, 363, 367, 469, 545, 561, 727, 769, 773, 781);
  for (int i = 1; i < 900; i += 2) {
    if (!falsePositives.contains(i)) {
      assertFalse("BF should not contain " + i, bf.mightContain(Integer.toString(i)));
    }
  }

  // Check that there are exactly 29824 false positives for this BF.
  int knownNumberOfFalsePositives = 29824;
  int numFpp = 0;
  for (int i = 1; i < numInsertions * 2; i += 2) {
    if (bf.mightContain(Integer.toString(i))) {
      numFpp++;
    }
  }
  assertEquals(knownNumberOfFalsePositives, numFpp);
  double actualFpp = (double) knownNumberOfFalsePositives / numInsertions;
  double expectedFpp = bf.expectedFpp();
  // The normal order of (expected, actual) is reversed here on purpose.
  assertEquals(actualFpp, expectedFpp, 0.00015);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:41,代码来源:BloomFilterTest.java

示例11: testCreateAndCheckBloomFilterWithKnownFalsePositives64

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public void testCreateAndCheckBloomFilterWithKnownFalsePositives64() {
  int numInsertions = 1000000;
  BloomFilter<String> bf = BloomFilter.create(
      Funnels.unencodedCharsFunnel(), numInsertions, 0.03,
      BloomFilterStrategies.MURMUR128_MITZ_64);

  // Insert "numInsertions" even numbers into the BF.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    bf.put(Integer.toString(i));
  }

  // Assert that the BF "might" have all of the even numbers.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    assertTrue(bf.mightContain(Integer.toString(i)));
  }

  // Now we check for known false positives using a set of known false positives.
  // (These are all of the false positives under 900.)
  ImmutableSet<Integer> falsePositives = ImmutableSet.of(
      15, 25, 287, 319, 381, 399, 421, 465, 529, 697, 767, 857);
  for (int i = 1; i < 900; i += 2) {
    if (!falsePositives.contains(i)) {
      assertFalse("BF should not contain " + i, bf.mightContain(Integer.toString(i)));
    }
  }

  // Check that there are exactly 30104 false positives for this BF.
  int knownNumberOfFalsePositives = 30104;
  int numFpp = 0;
  for (int i = 1; i < numInsertions * 2; i += 2) {
    if (bf.mightContain(Integer.toString(i))) {
      numFpp++;
    }
  }
  assertEquals(knownNumberOfFalsePositives, numFpp);
  double actualFpp = (double) knownNumberOfFalsePositives / numInsertions;
  double expectedFpp = bf.expectedFpp();
  // The normal order of (expected, actual) is reversed here on purpose.
  assertEquals(actualFpp, expectedFpp, 0.00033);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:41,代码来源:BloomFilterTest.java

示例12: testCreateAndCheckBloomFilterWithKnownUtf8FalsePositives64

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public void testCreateAndCheckBloomFilterWithKnownUtf8FalsePositives64() {
  int numInsertions = 1000000;
  BloomFilter<String> bf = BloomFilter.create(
      Funnels.stringFunnel(UTF_8), numInsertions, 0.03,
      BloomFilterStrategies.MURMUR128_MITZ_64);

  // Insert "numInsertions" even numbers into the BF.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    bf.put(Integer.toString(i));
  }

  // Assert that the BF "might" have all of the even numbers.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    assertTrue(bf.mightContain(Integer.toString(i)));
  }

  // Now we check for known false positives using a set of known false positives.
  // (These are all of the false positives under 900.)
  ImmutableSet<Integer> falsePositives =
      ImmutableSet.of(129, 471, 723, 89, 751, 835, 871);
  for (int i = 1; i < 900; i += 2) {
    if (!falsePositives.contains(i)) {
      assertFalse("BF should not contain " + i, bf.mightContain(Integer.toString(i)));
    }
  }

  // Check that there are exactly 29763 false positives for this BF.
  int knownNumberOfFalsePositives = 29763;
  int numFpp = 0;
  for (int i = 1; i < numInsertions * 2; i += 2) {
    if (bf.mightContain(Integer.toString(i))) {
      numFpp++;
    }
  }
  assertEquals(knownNumberOfFalsePositives, numFpp);
  double actualFpp = (double) knownNumberOfFalsePositives / numInsertions;
  double expectedFpp = bf.expectedFpp();
  // The normal order of (expected, actual) is reversed here on purpose.
  assertEquals(actualFpp, expectedFpp, 0.00033);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:41,代码来源:BloomFilterTest.java

示例13: isInMainDexList

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private boolean isInMainDexList(DexType iface) {
  ImmutableSet<DexType> list = converter.application.mainDexList;
  return list.contains(iface);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:5,代码来源:InterfaceMethodRewriter.java

示例14: wrap

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Override
public LinkingStore wrap(final Iterable<Symbol> docIDs) {
  final ImmutableSet<Symbol> docIdSet = ImmutableSet.copyOf(docIDs);

  return new LinkingStore() {
    @Override
    public ImmutableSet<Symbol> docIDs() throws IOException {
      return docIdSet;
    }

    @Override
    public Optional<ResponseLinking> read(final ArgumentOutput argumentOutput) throws IOException {
      if (docIdSet.contains(argumentOutput.docId())) {
        return Optional.of(linkResponses(argumentOutput));
      } else {
        return Optional.absent();
      }
    }

    @Override
    public Optional<ResponseLinking> read(final AnswerKey answerKey) throws IOException {

      if (docIdSet.contains(answerKey.docId())) {
        return Optional.of(linkResponses(answerKey));
      } else {
        return Optional.absent();
      }
    }

    @Override
    public void write(final ResponseLinking toWrite) throws IOException {
      throw new UnsupportedOperationException();
    }

    @Override
    public void close() throws IOException {
      // do nothing, assume underlying argumentStore will be closed separately
    }

    @Override
    public Optional<ResponseLinking> readTransformingIDs(final Symbol docID,
        final Set<Response> responses,
        final Optional<ImmutableMap<String, String>> foreignResponseIDToLocal,
        final Optional<ImmutableMap.Builder<String, String>> foreignLinkingIDToLocal)
        throws IOException {
      throw new UnsupportedOperationException();
    }
  };
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:50,代码来源:AbstractLinkingStrategy.java

示例15: testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public void testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives() {
  int numInsertions = 1000000;
  BloomFilter<String> bf = BloomFilter.create(
      Funnels.unencodedCharsFunnel(), numInsertions, 0.03,
      BloomFilterStrategies.MURMUR128_MITZ_32);

  // Insert "numInsertions" even numbers into the BF.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    bf.put(Integer.toString(i));
  }
  assertApproximateElementCountGuess(bf, numInsertions);

  // Assert that the BF "might" have all of the even numbers.
  for (int i = 0; i < numInsertions * 2; i += 2) {
    assertTrue(bf.mightContain(Integer.toString(i)));
  }

  // Now we check for known false positives using a set of known false positives.
  // (These are all of the false positives under 900.)
  ImmutableSet<Integer> falsePositives = ImmutableSet.of(
      49, 51, 59, 163, 199, 321, 325, 363, 367, 469, 545, 561, 727, 769, 773, 781);
  for (int i = 1; i < 900; i += 2) {
    if (!falsePositives.contains(i)) {
      assertFalse("BF should not contain " + i, bf.mightContain(Integer.toString(i)));
    }
  }

  // Check that there are exactly 29824 false positives for this BF.
  int knownNumberOfFalsePositives = 29824;
  int numFpp = 0;
  for (int i = 1; i < numInsertions * 2; i += 2) {
    if (bf.mightContain(Integer.toString(i))) {
      numFpp++;
    }
  }
  assertEquals(knownNumberOfFalsePositives, numFpp);
  double actualFpp = (double) knownNumberOfFalsePositives / numInsertions;
  double expectedFpp = bf.expectedFpp();
  // The normal order of (expected, actual) is reversed here on purpose.
  assertEquals(actualFpp, expectedFpp, 0.00015);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:42,代码来源:BloomFilterTest.java


注:本文中的com.google.common.collect.ImmutableSet.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。