/** * Creates the new instance that merges this and the given one via logical OR. * * @param that the other instance * @return this merged instance */ public Bitmask or(Bitmask that) { Bitmask copy = new Bitmask(this, that.bits.length << WORD_ADDRESS_BITS); return copy.orInPlace(that); }
/** * Creates the new instance that merges this and the given one via logical AND. * * @param that the other instance * @return this merged instance */ public Bitmask and(Bitmask that) { Bitmask copy = new Bitmask(this, that.bits.length << WORD_ADDRESS_BITS); return copy.andInPlace(that); }
/** * Creates the new instance that merges this and the given one via logical AND NOT. * * @param that the other instance * @return this merged instance */ public Bitmask andNot(Bitmask that) { Bitmask copy = new Bitmask(this, that.bits.length << WORD_ADDRESS_BITS); return copy.andNotInPlace(that); }
/** * Creates a new instance with a single {@link TreeVertex}. * * @param channelDescriptor represented by the {@link TreeVertex} * @param settledIndices indices to destinations settled by the {@code channelDescriptor} * @return the new instance */ static Tree singleton(ChannelDescriptor channelDescriptor, Bitmask settledIndices) { return new Tree(new TreeVertex(channelDescriptor, settledIndices), new Bitmask(settledIndices)); }
/** * Starts the actual search. */ private Tree searchTree() { // Prepare the recursive traversal. final HashSet<ChannelDescriptor> visitedChannelDescriptors = new HashSet<>(16); visitedChannelDescriptors.add(this.sourceChannelDescriptor); // Perform the traversal. final Map<Bitmask, Tree> solutions = this.enumerate( visitedChannelDescriptors, this.sourceChannelDescriptor, Bitmask.EMPTY_BITMASK, this.sourceChannelDescriptor.isSuitableForBreakpoint() ); // Get hold of a comprehensive solution (if it exists). Bitmask requestedIndices = new Bitmask(this.destChannelDescriptorSets.size()); requestedIndices.flip(0, this.destChannelDescriptorSets.size()); return solutions.get(requestedIndices); }
for (Set<ChannelDescriptor> destChannelDescriptorSet : this.destChannelDescriptorSets) { final Bitmask indices = this.kernelDestChannelDescriptorSetsToIndices.computeIfAbsent( destChannelDescriptorSet, key -> new Bitmask(this.destChannelDescriptorSets.size()) ); this.allDestinationChannelIndices.set(index); this.kernelDestChannelDescriptorSetsToIndices.computeIfAbsent( channelsToIndicesChange.getField0(), key -> new Bitmask(this.destChannelDescriptorSets.size()) ).orInPlace(channelsToIndicesChange.getField1()); this.kernelDestChannelDescriptorsToIndices.merge(channelDescriptor, new Bitmask(indices), Bitmask::or);
Bitmask combinationSettledIndices = new Bitmask(firstTree.settledDestinationIndices); int maxSettledIndices = combinationSettledIndices.cardinality(); final HashSet<ChannelDescriptor> employedChannelDescriptors = new HashSet<>(firstTree.employedChannelDescriptors);
this.existingDestinationChannelIndices = new Bitmask(); this.existingChannels = Collections.emptyMap(); this.existingDestinationChannels = Collections.emptyMap(); this.existingDestinationChannelIndices = new Bitmask(); this.openChannelDescriptors = Collections.emptySet(); this.reachableExistingDestinationChannelIndices.compute( existingDestinationChannel.getDescriptor(), (k, v) -> v == null ? new Bitmask(channelIndices) : v.orInPlace(channelIndices) ); if (existingDestinationChannel.getDescriptor().equals(this.sourceChannelDescriptor)) break;
Bitmask newSettledIndicesSubset = new Bitmask(index + 1); newSettledIndicesSubset.set(index); newSolution = Tree.singleton(channelDescriptor, newSettledIndicesSubset);