本文整理了Java中java.util.LinkedHashSet.contains()
方法的一些代码示例,展示了LinkedHashSet.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashSet.contains()
方法的具体详情如下:
包路径:java.util.LinkedHashSet
类名称:LinkedHashSet
方法名:contains
暂无
代码示例来源:origin: apache/flink
/**
* Registers the given type with the serialization stack. If the type is eventually
* serialized as a POJO, then the type is registered with the POJO serializer. If the
* type ends up being serialized with Kryo, then it will be registered at Kryo to make
* sure that only tags are written.
*
* @param type The class of the type to register.
*/
public void registerPojoType(Class<?> type) {
if (type == null) {
throw new NullPointerException("Cannot register null type class.");
}
if (!registeredPojoTypes.contains(type)) {
registeredPojoTypes.add(type);
}
}
代码示例来源:origin: apache/flink
/**
* Returns the registered Kryo types.
*/
public LinkedHashSet<Class<?>> getRegisteredKryoTypes() {
if (isForceKryoEnabled()) {
// if we force kryo, we must also return all the types that
// were previously only registered as POJO
LinkedHashSet<Class<?>> result = new LinkedHashSet<>();
result.addAll(registeredKryoTypes);
for(Class<?> t : registeredPojoTypes) {
if (!result.contains(t)) {
result.add(t);
}
}
return result;
} else {
return registeredKryoTypes;
}
}
代码示例来源:origin: apache/maven
private static Iterable<String> getDistinctPhasesInOrderOfExecutionPlanAppearance(
List<ExecutionPlanItem> planItems )
{
LinkedHashSet<String> result = new LinkedHashSet<>();
for ( ExecutionPlanItem executionPlanItem : planItems )
{
final String phase = executionPlanItem.getLifecyclePhase();
if ( !result.contains( phase ) )
{
result.add( phase );
}
}
return result;
}
代码示例来源:origin: DozerMapper/dozer
&& result.contains(destValue)) {
List<Object> resultAsList = new ArrayList<>(result);
int index = resultAsList.indexOf(destValue);
result.add(destValue);
代码示例来源:origin: square/leakcanary
if (toVisitSet.contains(child)) {
return;
if (!visitNow && toVisitIfNoPathSet.contains(child)) {
return;
return;
if (visitedSet.contains(child)) {
return;
toVisitSet.add(child);
toVisitQueue.add(childNode);
} else {
toVisitIfNoPathSet.add(child);
toVisitIfNoPathQueue.add(childNode);
代码示例来源:origin: jersey/jersey
/**
* Get collection of all {@link ServiceHolder}s bound for providers (custom and default) registered for the given service
* provider contract in the underlying {@link InjectionManager injection manager} container.
*
* @param <T> service provider contract Java type.
* @param injectionManager underlying injection manager.
* @param contract service provider contract.
* @return set of all available service provider instances for the contract
*/
public static <T> Collection<ServiceHolder<T>> getAllServiceHolders(InjectionManager injectionManager, Class<T> contract) {
List<ServiceHolder<T>> providers = getServiceHolders(injectionManager,
contract,
Comparator.comparingInt(Providers::getPriority),
CustomAnnotationLiteral.INSTANCE);
providers.addAll(getServiceHolders(injectionManager, contract));
LinkedHashSet<ServiceHolder<T>> providersSet = new LinkedHashSet<>();
for (ServiceHolder<T> provider : providers) {
if (!providersSet.contains(provider)) {
providersSet.add(provider);
}
}
return providersSet;
}
代码示例来源:origin: jersey/jersey
/**
* Get collection of all {@link ServiceHolder}s bound for providers (custom and default) registered for the given service
* provider contract in the underlying {@link InjectionManager injection manager} container.
*
* @param <T> service provider contract Java type.
* @param injectionManager underlying injection manager.
* @param contract service provider contract.
* @return set of all available service provider instances for the contract
*/
public static <T> Collection<ServiceHolder<T>> getAllServiceHolders(InjectionManager injectionManager, Class<T> contract) {
List<ServiceHolder<T>> providers = getServiceHolders(injectionManager,
contract,
Comparator.comparingInt(Providers::getPriority),
CustomAnnotationLiteral.INSTANCE);
providers.addAll(getServiceHolders(injectionManager, contract));
LinkedHashSet<ServiceHolder<T>> providersSet = new LinkedHashSet<>();
for (ServiceHolder<T> provider : providers) {
if (!providersSet.contains(provider)) {
providersSet.add(provider);
}
}
return providersSet;
}
代码示例来源:origin: azkaban/azkaban
if (visitedVariables.contains(subVariable)) {
throw new IllegalArgumentException(String.format(
"Circular variable substitution found: [%s] -> [%s]",
visitedVariables.add(subVariable);
代码示例来源:origin: apache/kafka
private void addRandomElement(Random random, LinkedHashSet<Integer> existing,
ImplicitLinkedHashSet<TestElement> set) {
int next;
do {
next = random.nextInt();
} while (existing.contains(next));
existing.add(next);
set.add(new TestElement(next));
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
String name = StringUtil.decapitalize(callReference.getIdentifier().getText());
for (String candidate : NameUtil.getSuggestionsByName(name, "", "", false, false, false)) {
if (usedNames.contains(candidate)) continue;
if (!isValidName(namesValidator, candidate)) continue;
names.add(candidate);
boolean array = GoTypeUtil.isIterable(type) && !GoTypeUtil.isString(type);
for (String candidate : NameUtil.getSuggestionsByName(typeText, "", "", false, false, array)) {
if (usedNames.contains(candidate) || typeText.equals(candidate)) continue;
if (!isValidName(namesValidator, candidate)) continue;
names.add(candidate);
names.add(UniqueNameGenerator.generateUniqueName("i", usedNames));
代码示例来源:origin: apache/hive
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: apache/hive
retainableOps.add(equalOp1);
discardableOps.add(equalOp2);
if (equalOp1 instanceof MapJoinOperator) {
MapJoinOperator mop = (MapJoinOperator) equalOp1;
if (op instanceof MapJoinOperator && !retainableOps.contains(op)) {
MapJoinOperator mop = (MapJoinOperator) op;
dataSize = StatsUtils.safeAdd(dataSize, mop.getConf().getInMemoryDataSize());
if (op instanceof MapJoinOperator && !discardableOps.contains(op)) {
MapJoinOperator mop = (MapJoinOperator) op;
dataSize = StatsUtils.safeAdd(dataSize, mop.getConf().getInMemoryDataSize());
代码示例来源:origin: cmusphinx/sphinx4
queue.add(reversed.getStart());
.getNextState().getId()], semiring.times(rnew,
a.getWeight()));
if (!queue.contains(nextState)) {
queue.add(nextState);
代码示例来源:origin: apache/drill
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!rel.indicator && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: lenskit/lenskit
/**
* Add a column to the table layout. Each column must have a unique, non-null
* name.
*
* @param name The column name.
* @return The builder, for chaining.
* @throws IllegalArgumentException if the column already exists.
*/
public TableLayoutBuilder addColumn(String name) {
if (name == null) {
throw new NullPointerException("column name");
}
if (columns.contains(name)) {
throw new IllegalArgumentException("column " + name + " already exists");
}
columns.add(name);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
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;
}
代码示例来源:origin: org.apache.hadoop/hadoop-hdfs
public synchronized void markSuspectBlock(ExtendedBlock block) {
if (stopping) {
LOG.debug("{}: Not scheduling suspect block {} for " +
"rescanning, because this volume scanner is stopping.", this, block);
return;
}
Boolean recent = recentSuspectBlocks.getIfPresent(block);
if (recent != null) {
LOG.debug("{}: Not scheduling suspect block {} for " +
"rescanning, because we rescanned it recently.", this, block);
return;
}
if (suspectBlocks.contains(block)) {
LOG.debug("{}: suspect block {} is already queued for " +
"rescanning.", this, block);
return;
}
suspectBlocks.add(block);
recentSuspectBlocks.put(block, true);
LOG.debug("{}: Scheduling suspect block {} for rescanning.", this, block);
notify(); // wake scanner thread.
}
代码示例来源:origin: stephanenicolas/toothpick
@Override
public void checkCyclesStart(Class clazz, String name) {
final Pair pair = new Pair(clazz, name);
final LinkedHashSet<Pair> linkedHashSet = cycleDetectionStack.get();
if (linkedHashSet.contains(pair)) {
throw new CyclicDependencyException(Pair.getClassList(linkedHashSet), clazz);
}
linkedHashSet.add(pair);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
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;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private static void addSortedBundle(Bundle bundle, Map<String, Bundle> bundles, LinkedHashSet<Bundle> sortedBundles,
LinkedHashSet<String> dependencyStack) {
String name = bundle.plugin.getName();
if (dependencyStack.contains(name)) {
StringBuilder msg = new StringBuilder("Cycle found in plugin dependencies: ");
dependencyStack.forEach(s -> {
msg.append(s);
msg.append(" -> ");
});
msg.append(name);
throw new IllegalStateException(msg.toString());
}
if (sortedBundles.contains(bundle)) {
// already added this plugin, via a dependency
return;
}
dependencyStack.add(name);
for (String dependency : bundle.plugin.getExtendedPlugins()) {
Bundle depBundle = bundles.get(dependency);
if (depBundle == null) {
throw new IllegalArgumentException("Missing plugin [" + dependency + "], dependency of [" + name + "]");
}
addSortedBundle(depBundle, bundles, sortedBundles, dependencyStack);
assert sortedBundles.contains(depBundle);
}
dependencyStack.remove(name);
sortedBundles.add(bundle);
}
内容来源于网络,如有侵权,请联系作者删除!