Java Code Examples for com.google.common.collect.Sets#newIdentityHashSet()
The following examples show how to use
com.google.common.collect.Sets#newIdentityHashSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperatorStep.java From yql-plus with Apache License 2.0 | 6 votes |
@Override public Set<? extends Value> getInputs() { if (compute != null) { final Set<Value> inputs = Sets.newIdentityHashSet(); compute.visitNode(new OperatorTreeVisitor() { @Override public void visit(Object arg) { if (arg instanceof Value) { inputs.add((Value) arg); } } }); inputs.addAll(before); return inputs; } else { return before; } }
Example 2
Source File: DataContextImpl.java From cuba with Apache License 2.0 | 6 votes |
@Override public EntitySet merge(Collection<? extends Entity> entities) { checkNotNullArgument(entities, "entity collection is null"); List<Entity> managedList = new ArrayList<>(entities.size()); disableListeners = true; try { Set<Entity> merged = Sets.newIdentityHashSet(); for (Entity entity : entities) { Entity managed = internalMerge(entity, merged, true); managedList.add(managed); } } finally { disableListeners = false; } return EntitySet.of(managedList); }
Example 3
Source File: JavascriptExactVariableBindingsExtractor.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final VariableBindingFinder bindingFinder = new VariableBindingFinder(); node.accept(bindingFinder); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<IVariableBinding, List<ASTNode>> variableBindings : bindingFinder.variableScope .entrySet()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.addAll(variableBindings.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 4
Source File: JavaMethodInvocationBindingExtractor.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final MethodBindings mb = new MethodBindings(); node.accept(mb); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<String, ASTNode> entry : mb.methodNamePostions .entries()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.add(entry.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 5
Source File: ExceptionUtils.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Returns the first throwable of the given {@code wantedThrowableType} by visiting the provided * throwable and its causes recursively. * * @param wantedThrowableType the throwable type to find * @param throwable the throwable to start with * @param <T> the desired throwable subtype * @return the first throwable found of the given type, or null if none found */ public static <T extends Throwable> T findThrowableInCause(Class<T> wantedThrowableType, Throwable throwable) { Set<Throwable> visitedObjects = Sets.newIdentityHashSet(); Throwable currentThrowable = throwable; while (currentThrowable != null && !visitedObjects.contains(currentThrowable)) { if (wantedThrowableType.isInstance(currentThrowable)) { return wantedThrowableType.cast(currentThrowable); } visitedObjects.add(currentThrowable); currentThrowable = currentThrowable.getCause(); } return null; }
Example 6
Source File: JavaApproximateVariableBindingExtractor.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final VariableBindingFinder bindingFinder = new VariableBindingFinder(); node.accept(bindingFinder); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding .entrySet()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.addAll(variableBindings.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 7
Source File: GeometryUtils.java From OpenModsLib with MIT License | 5 votes |
private static EnumSet<Octant> select(EnumFacing dir) { Set<Octant> result = Sets.newIdentityHashSet(); for (Octant o : values()) if (o.dirs.contains(dir)) result.add(o); return EnumSet.copyOf(result); }
Example 8
Source File: JavaApproximateVariableBindingExtractor.java From api-mining with GNU General Public License v3.0 | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final VariableBindingFinder bindingFinder = new VariableBindingFinder(); node.accept(bindingFinder); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding .entrySet()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.addAll(variableBindings.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 9
Source File: JavaMethodInvocationBindingExtractor.java From api-mining with GNU General Public License v3.0 | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final MethodBindings mb = new MethodBindings(); node.accept(mb); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<String, ASTNode> entry : mb.methodNamePostions .entries()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.add(entry.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 10
Source File: DynamicFilterPipeline.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public void destroyPipeline() { servletPipeline.destroy(); Set<Filter> destroyedSoFar = Sets.newIdentityHashSet(); for (FilterDefinition filterDefinition : filterDefinitions()) { filterDefinition.destroy(destroyedSoFar); } }
Example 11
Source File: SubstitutionVisitor.java From Bats with Apache License 2.0 | 5 votes |
public SubstitutionVisitor(RelNode target_, RelNode query_, ImmutableList<UnifyRule> rules, RelBuilderFactory relBuilderFactory) { this.cluster = target_.getCluster(); final RexExecutor executor = Util.first(cluster.getPlanner().getExecutor(), RexUtil.EXECUTOR); final RelOptPredicateList predicates = RelOptPredicateList.EMPTY; this.simplify = new RexSimplify(cluster.getRexBuilder(), predicates, executor); this.rules = rules; this.query = Holder.of(MutableRels.toMutable(query_)); this.target = MutableRels.toMutable(target_); this.relBuilder = relBuilderFactory.create(cluster, null); final Set<MutableRel> parents = Sets.newIdentityHashSet(); final List<MutableRel> allNodes = new ArrayList<>(); final MutableRelVisitor visitor = new MutableRelVisitor() { @Override public void visit(MutableRel node) { parents.add(node.getParent()); allNodes.add(node); super.visit(node); } }; visitor.go(target); // Populate the list of leaves in the tree under "target". // Leaves are all nodes that are not parents. // For determinism, it is important that the list is in scan order. allNodes.removeAll(parents); targetLeaves = ImmutableList.copyOf(allNodes); allNodes.clear(); parents.clear(); visitor.go(query); allNodes.removeAll(parents); queryLeaves = ImmutableList.copyOf(allNodes); }
Example 12
Source File: DataContextImpl.java From cuba with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public <T extends Entity> T merge(T entity) { checkNotNullArgument(entity, "entity is null"); disableListeners = true; T result; try { Set<Entity> merged = Sets.newIdentityHashSet(); result = (T) internalMerge(entity, merged, true); } finally { disableListeners = false; } return result; }
Example 13
Source File: IsValidBoundedLocalCache.java From caffeine with Apache License 2.0 | 5 votes |
private void checkTimerWheel(BoundedLocalCache<K, V> cache) { if (!cache.expiresVariable()) { return; } Set<Node<K, V>> seen = Sets.newIdentityHashSet(); for (int i = 0; i < cache.timerWheel().wheel.length; i++) { for (int j = 0; j < cache.timerWheel().wheel[i].length; j++) { Node<K, V> sentinel = cache.timerWheel().wheel[i][j]; desc.expectThat("Wrong sentinel prev", sentinel.getPreviousInVariableOrder().getNextInVariableOrder(), sameInstance(sentinel)); desc.expectThat("Wrong sentinel next", sentinel.getNextInVariableOrder().getPreviousInVariableOrder(), sameInstance(sentinel)); desc.expectThat("Sentinel must be first element", sentinel, instanceOf(Sentinel.class)); for (Node<K, V> node = sentinel.getNextInVariableOrder(); node != sentinel; node = node.getNextInVariableOrder()) { Node<K, V> next = node.getNextInVariableOrder(); Node<K, V> prev = node.getPreviousInVariableOrder(); long duration = node.getVariableTime() - cache.timerWheel().nanos; desc.expectThat("Expired", duration, greaterThan(0L)); desc.expectThat("Loop detected", seen.add(node), is(true)); desc.expectThat("Wrong prev", prev.getNextInVariableOrder(), is(sameInstance(node))); desc.expectThat("Wrong next", next.getPreviousInVariableOrder(), is(sameInstance(node))); } } } desc.expectThat("Timers != Entries", seen, hasSize(cache.size())); }
Example 14
Source File: JavaApproximateVariableBindingExtractor.java From codemining-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final VariableBindingFinder bindingFinder = new VariableBindingFinder(); node.accept(bindingFinder); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding .entrySet()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.addAll(variableBindings.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 15
Source File: JavaMethodInvocationBindingExtractor.java From codemining-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Set<Set<ASTNode>> getNameBindings(final ASTNode node) { final MethodBindings mb = new MethodBindings(); node.accept(mb); final Set<Set<ASTNode>> nameBindings = Sets.newHashSet(); for (final Entry<String, ASTNode> entry : mb.methodNamePostions .entries()) { final Set<ASTNode> boundNodes = Sets.newIdentityHashSet(); boundNodes.add(entry.getValue()); nameBindings.add(boundNodes); } return nameBindings; }
Example 16
Source File: IsValidBoundedLocalCache.java From caffeine with Apache License 2.0 | 5 votes |
private void checkLinks(BoundedLocalCache<K, V> cache, ImmutableList<LinkedDeque<Node<K, V>>> deques, DescriptionBuilder desc) { int size = 0; long weightedSize = 0; Set<Node<K, V>> seen = Sets.newIdentityHashSet(); for (LinkedDeque<Node<K, V>> deque : deques) { size += deque.size(); weightedSize += scanLinks(cache, seen, deque, desc); } if (cache.size() != size) { desc.expectThat(() -> "deque size " + deques, size, is(cache.size())); } Supplier<String> errorMsg = () -> String.format( "Size != list length; pending=%s, additional: %s", cache.writeBuffer().size(), Sets.difference(seen, ImmutableSet.copyOf(cache.data.values()))); desc.expectThat(errorMsg, cache.size(), is(seen.size())); if (cache.evicts()) { long weighted = weightedSize; long expectedWeightedSize = Math.max(0, cache.weightedSize()); Supplier<String> error = () -> String.format( "WeightedSize != link weights [%d vs %d] {%d vs %d}", expectedWeightedSize, weighted, seen.size(), cache.size()); desc.expectThat("non-negative weight", weightedSize, is(greaterThanOrEqualTo(0L))); desc.expectThat(error, expectedWeightedSize, is(weightedSize)); } }
Example 17
Source File: TypeParamCollector.java From mesh with MIT License | 4 votes |
private Set<TypeParam> process(final Type type) { params = Sets.newIdentityHashSet(); visitType(type); return params; }
Example 18
Source File: ChangingIdentifiersRepositoryWalker.java From naturalize with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visitDiffEntry(final DiffEntry entry, final EditList editList, final RevCommit commit) throws IOException { final String sha = commit.name(); if (entry.getNewPath().equals("/dev/null")) { currentStateOfIdentifiers.removeAll(entry.getOldPath()).forEach( i -> { if (!i.isDeleted()) { i.setIdentifierDeleted(); } }); return; } final String repositoryFolder = repository.getRepository() .getWorkTree() + "/"; final File targetFile = new File(repositoryFolder + entry.getNewPath()); final Set<IdentifierInformation> newIdentifierInfo = infoScanner .scanFile(targetFile, commit.name()); if (currentStateOfIdentifiers.containsKey(entry.getOldPath())) { final Collection<IdentifierInformationThroughTime> state = currentStateOfIdentifiers .get(entry.getOldPath()); final List<IdentifierInformationThroughTime> allIitts = Lists .newArrayList(state); final Set<IdentifierInformationThroughTime> setIitts = Sets .newIdentityHashSet(); setIitts.addAll(state); checkArgument(setIitts.size() == allIitts.size(), "Before adding, state was inconsistent for ", targetFile); updateIdentifierInfoState(state, newIdentifierInfo, editList, entry.getNewPath()); if (!entry.getOldPath().equals(entry.getNewPath())) { currentStateOfIdentifiers.putAll(entry.getNewPath(), state); currentStateOfIdentifiers.removeAll(entry.getOldPath()); } } else { // This is a new file or a file we failed to index before, add // happily... // checkArgument(entry.getOldPath().equals("/dev/null")); final List<IdentifierInformationThroughTime> infosThroughTime = Lists .newArrayList(); newIdentifierInfo .forEach(info -> { final IdentifierInformationThroughTime inf = new IdentifierInformationThroughTime(); inf.addInformation(info); infosThroughTime.add(inf); }); currentStateOfIdentifiers.putAll(entry.getNewPath(), infosThroughTime); } }
Example 19
Source File: RelUniqifier.java From dremio-oss with Apache License 2.0 | 4 votes |
public static Prel uniqifyGraph(Prel p) { Set<Prel> data = Sets.newIdentityHashSet(); return p.accept(INSTANCE, data); }
Example 20
Source File: SyncMapClient.java From OpenModsLib with MIT License | 3 votes |
@Override public void readIntializationData(PacketBuffer dis) throws IOException { final int count = dis.readVarInt(); final ImmutableList.Builder<ISyncableObject> idToObject = ImmutableList.builder(); final ImmutableMap.Builder<ISyncableObject, Integer> objectToId = ImmutableMap.builder(); final Set<ISyncableObject> changedObjects = Sets.newIdentityHashSet(); for (int i = 0; i < count; i++) { final String id = dis.readString(Short.MAX_VALUE); final int typeId = dis.readVarInt(); final SyncableObjectType type = SyncableObjectTypeRegistry.getType(typeId); ISyncableObject object = availableObjects.get(id); if (object == null || !type.isValidType(object)) object = type.createDummyObject(); object.readFromStream(dis); idToObject.add(object); objectToId.put(object, i); changedObjects.add(object); } this.idToObject = idToObject.build(); this.objectToId = objectToId.build(); this.bitmapLength = (count + 7) / 8; notifySyncListeners(updateListeners, Collections.unmodifiableSet(changedObjects)); }