/** * Static constructor-like method similar to other (generic) collections. * * @return New instance. */ public static BitSet newInstance() { return new BitSet(); }
/** * Static constructor-like method similar to other (generic) collections. * * @return New instance. */ public static BitSet newInstance() { return new BitSet(); }
private BitSet getBitSet(int level) { while (bsets.size() <= level) bsets.add(new BitSet()); return bsets.get(level); } };
ClusterCandidate() { this.phrases = Lists.newArrayList(); this.documents = new BitSet(); }
public SegmentationDefinition getSubsetDefinition(int wordsetSize) { /* * Code the combinations of elements not with ids but with bits. 01 is * only the first element, 10 is the second and 11 is the combination of * both. */ int mask = (1 << wordsetSize) - 1; int conditions[][] = new int[][] { { mask } }; int segments[] = new int[] { mask }; BitSet neededCounts = new BitSet(1 << wordsetSize); neededCounts.set(mask); return new SegmentationDefinition(segments, conditions, neededCounts); }
/** * Verifies that the tree is in a valid shape. * * @throws IllegalStateException for invalid trees. */ public void verifyTreeIntegrity() { BitSet seen = new BitSet(capacity); for (int child : children) { if (child != INVALID_NODE) { if (seen.getAndSet(child)) { throw new IllegalStateException("node (" + child + ") has multiple parents"); } } } for (int sibling : siblings) { if (sibling != INVALID_NODE) { if (seen.getAndSet(sibling)) { throw new IllegalStateException("node (" + sibling + ") has multiple parents"); } } } }
/** * Verifies that the tree is in a valid shape. * * @throws IllegalStateException for invalid trees. */ public void verifyTreeIntegrity() { BitSet seen = new BitSet(capacity); for (int child : children) { if (child != INVALID_NODE) { if (seen.getAndSet(child)) { throw new IllegalStateException("node (" + child + ") has multiple parents"); } } } for (int sibling : siblings) { if (sibling != INVALID_NODE) { if (seen.getAndSet(sibling)) { throw new IllegalStateException("node (" + sibling + ") has multiple parents"); } } } }
public Dijkstra(Graph graph) { this.graph = graph; nodeCount = Math.toIntExact(graph.nodeCount()); costs = new IntDoubleScatterMap(nodeCount); queue = SharedIntPriorityQueue.min(nodeCount, costs, Double.MAX_VALUE); path = new IntIntScatterMap(nodeCount); visited = new BitSet(nodeCount); depth = new int[nodeCount]; }
public Dijkstra(Graph graph) { this.graph = graph; nodeCount = Math.toIntExact(graph.nodeCount()); costs = new IntDoubleScatterMap(nodeCount); queue = SharedIntPriorityQueue.min(nodeCount, costs, Double.MAX_VALUE); path = new IntIntScatterMap(nodeCount); visited = new BitSet(nodeCount); depth = new int[nodeCount]; }
private BitSet[] createBitSets(IntOpenHashSet hashSets[], IntOpenHashSet mergedHashSet) { BitSet bitSets[] = new BitSet[hashSets.length]; for (int i = 0; i < bitSets.length; ++i) { bitSets[i] = new BitSet(mergedHashSet.size()); } int pos = 0; for (int i = 0; i < mergedHashSet.keys.length; i++) { if (mergedHashSet.allocated[i]) { for (int j = 0; j < bitSets.length; ++j) { if (hashSets[j].contains(mergedHashSet.keys[i])) { bitSets[j].set(pos); } } ++pos; } } return bitSets; }
public SegmentationDefinition getSubsetDefinition(int wordsetSize) { /* * Code the combinations of elements not with ids but with bits. 01 is * only the first element, 10 is the second and 11 is the combination of * both. */ int conditions[][] = new int[wordsetSize][1]; int segments[] = new int[wordsetSize]; int bit = 1, pos = 0; int mask = (1 << wordsetSize) - 1; BitSet neededCounts = new BitSet(1 << wordsetSize); while (bit < mask) { segments[pos] = bit; neededCounts.set(bit); conditions[pos] = new int[] { mask }; bit = bit << 1; ++pos; } neededCounts.set(mask); return new SegmentationDefinition(segments, conditions, neededCounts); }
public SegmentationDefinition getSubsetDefinition(int wordsetSize) { /* * Code the combinations of elements not with ids but with bits. 01 is * only the first element, 10 is the second and 11 is the combination of * both. */ int conditions[][] = new int[wordsetSize][1]; int segments[] = new int[wordsetSize]; int bit = 1, pos = 0; int mask = (1 << wordsetSize) - 1; BitSet neededCounts = new BitSet(1 << wordsetSize); while (bit < mask) { segments[pos] = mask - bit; neededCounts.set(segments[pos]); conditions[pos] = new int[] { bit }; bit = bit << 1; ++pos; } neededCounts.set(mask); return new SegmentationDefinition(segments, conditions, neededCounts); }
public SegmentationDefinition getSubsetDefinition(int wordsetSize) { /* * Code the combinations of elements not with ids but with bits. 01 is * only the first element, 10 is the second and 11 is the combination of * both. */ int conditions[][] = new int[wordsetSize][1]; int segments[] = new int[wordsetSize]; int bit = 1, pos = 0; int mask = (1 << wordsetSize) - 1; BitSet neededCounts = new BitSet(1 << wordsetSize); while (bit < mask) { segments[pos] = bit; neededCounts.set(bit); conditions[pos] = new int[] { mask - bit }; bit = bit << 1; ++pos; } neededCounts.set(mask); return new SegmentationDefinition(segments, conditions, neededCounts); }
/** * apply consumer to each connected community one time * * @param node node nodeId * @param consumer community nodeId consumer */ private void forEachConnectedCommunity(int node, IntConsumer consumer) { final BitSet visited = new BitSet(nodeCount); graph.forEachRelationship(node, D, (s, t, r) -> { final int c = localCommunities[t]; if (c == NONE) { return true; } if (visited.get(c)) { return true; } visited.set(c); consumer.accept(c); return true; }); }
public ShortestPathDijkstra(Graph graph) { this.graph = graph; nodeCount = Math.toIntExact(graph.nodeCount()); costs = new IntDoubleScatterMap(); queue = SharedIntPriorityQueue.min( IntPriorityQueue.DEFAULT_CAPACITY, costs, Double.MAX_VALUE); path = new IntIntScatterMap(); visited = new BitSet(); finalPath = new IntArrayDeque(); finalPathCosts = new DoubleArrayDeque(); progressLogger = getProgressLogger(); }
/** * apply consumer to each connected community one time * * @param node node nodeId * @param consumer community nodeId consumer */ private void forEachConnectedCommunity(int node, IntConsumer consumer) { final BitSet visited = new BitSet(nodeCount); graph.forEachRelationship(node, D, (s, t, r) -> { final int c = localCommunities[t]; if (c == NONE) { return true; } if (visited.get(c)) { return true; } visited.set(c); consumer.accept(c); return true; }); }
public ShortestPathDijkstra(Graph graph) { this.graph = graph; nodeCount = Math.toIntExact(graph.nodeCount()); costs = new IntDoubleScatterMap(); queue = SharedIntPriorityQueue.min( IntPriorityQueue.DEFAULT_CAPACITY, costs, Double.MAX_VALUE); path = new IntIntScatterMap(); visited = new BitSet(); finalPath = new IntArrayDeque(); finalPathCosts = new DoubleArrayDeque(); progressLogger = getProgressLogger(); }
public AbstractMultiStepTarjan compute(IntSet nodes) { indices = new IntIntScatterMap(nodes.size()); lowLink = new IntIntScatterMap(nodes.size()); stack = new IntStack(nodes.size()); onStack = new BitSet(); nodes.forEach((IntProcedure) this::strongConnect); return this; }
public AbstractMultiStepTarjan compute(IntSet nodes) { indices = new IntIntScatterMap(nodes.size()); lowLink = new IntIntScatterMap(nodes.size()); stack = new IntStack(nodes.size()); onStack = new BitSet(); nodes.forEach((IntProcedure) this::strongConnect); return this; }
private void iterateBFS(int startNode, RelationshipConsumer consumer) { IntArrayDeque queue = new IntArrayDeque(); BitSet seen = new BitSet(capacity); queue.addFirst(startNode); while (!queue.isEmpty()) { int node = queue.removeFirst(); int child = children[node]; if (child != INVALID_NODE) { do { if (!seen.getAndSet(child)) { queue.addLast(child); } if (!consumer.accept( node, child, RELATION_ID_NOT_SUPPORTED)) { return; } } while ((child = siblings[child]) != INVALID_NODE); } } }