public GHIntHashSet(IntContainer container) { this(container.size()); addAll(container); }
/** * multistep coloring algorithm task * * @param nodes nodes to process * @return container with nodes which must be processed in the next step */ private IntContainer msColorTask(IntContainer nodes) { final IntStack levelQueue = new IntStack(nodes.size()); nodes.forEach((IntProcedure) node -> { final int nodeColor = colors.get(node); final boolean[] change = {false}; graph.forEachRelationship(node, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { if (cas(targetNodeId, nodeColor)) { if (!visited.get(targetNodeId)) { visited.set(targetNodeId); levelQueue.push(targetNodeId); change[0] = true; } } return true; }); if (change[0] && !visited.get(node)) { levelQueue.push(node); visited.set(node); } }); return levelQueue; }
/** * This writes a feature's individual value, using the human readable name if possible, to a StringBuilder */ private void debugFeatureValue(String feature, int index, ConcatVector vector, BufferedWriter bw) throws IOException { bw.write("\t"); if (sparseFeatureIndex.containsKey(feature) && sparseFeatureIndex.get(feature).values().contains(index)) { // we can map this index to an interpretable string, so we do bw.write("SPARSE VALUE \""); bw.write(reverseSparseFeatureIndex.get(feature).get(index)); bw.write("\""); } else { // we can't map this to a useful string, so we default to the number bw.write(Integer.toString(index)); } bw.write(": "); bw.write(Double.toString(vector.getValueAt(featureToIndex.getOrDefault(feature, -1), index))); bw.write("\n"); } }
static public int max(IntContainer c) { int max = Integer.MIN_VALUE; for (int i : c.toArray()) max = Math.max(max, i); return max; }
private void resetColors(IntContainer nodes) { nodes.forEach((IntProcedure) node -> colors.set(node, node)); }
public IntIterator valuesIterator() { return new IntFailFastIterator(cursorToIntIterator(myMap.values().iterator())) { @Override protected int getCurrentModCount() { return myModCount; } }; }
/** * Creates a new list from the elements of another container in its * iteration order. */ public IntArrayList(IntContainer container) { this(container.size()); addAll(container); }
/** * multistep coloring algorithm task * * @param nodes nodes to process * @return container with nodes which must be processed in the next step */ private IntContainer msColorTask(IntContainer nodes) { final IntStack levelQueue = new IntStack(nodes.size()); nodes.forEach((IntProcedure) node -> { final int nodeColor = colors.get(node); final boolean[] change = {false}; graph.forEachRelationship(node, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { if (cas(targetNodeId, nodeColor)) { if (!visited.get(targetNodeId)) { visited.set(targetNodeId); levelQueue.push(targetNodeId); change[0] = true; } } return true; }); if (change[0] && !visited.get(node)) { levelQueue.push(node); visited.set(node); } }); return levelQueue; }
static public int min(IntContainer c) { int min = Integer.MAX_VALUE; for (int i : c.toArray()) min = Math.min(min, i); return min; }
private void resetColors(IntContainer nodes) { nodes.forEach((IntProcedure) node -> colors.set(node, node)); }
public IntIterator valuesIterator() { return new IntFailFastIterator(cursorToIntIterator(myMap.values().iterator())) { @Override protected int getCurrentModCount() { return myModCount; } }; }
/** * New instance copying elements from another {@link IntContainer}. */ public IntHashSet(IntContainer container) { this(container.size()); addAll(container); }
static public int min(IntContainer c) { int min = Integer.MAX_VALUE; for (int i : c.toArray()) min = Math.min(min, i); return min; }
@Override public void forEachRelationship(int nodeId, Direction direction, RelationshipConsumer consumer) { final IntContainer intCursors = graph.get(nodeId); if (null == intCursors) { return; } intCursors.forEach((IntProcedure) t -> consumer.accept(nodeId, t, -1)); }