int top = 0; IntIntHashMap entryVarMap = new IntIntHashMap(); for (int i = 0; i < argumentMapping.length; ++i) { Variable arg = argumentMapping[i]; Step step = stack[--top]; int node = step.node; IntIntMap varMap = new IntIntHashMap(step.varMap); BasicBlock block = program.basicBlockAt(node); result[node] = new IntIntHashMap(varMap); stack[top++] = new Step(successor, new IntIntHashMap(varMap));
@Override public int[] split(int[] domain, int[] nodes) { int[] copies = new int[nodes.length]; IntIntMap map = new IntIntHashMap(); for (int i = 0; i < nodes.length; ++i) { int node = nodes[i]; BasicBlock block = program.basicBlockAt(node); BasicBlock blockCopy = program.createBasicBlock(); ProgramUtils.copyBasicBlock(block, blockCopy); copies[i] = blockCopy.getIndex(); map.put(nodes[i], copies[i] + 1); } BasicBlockMapper copyBlockMapper = new BasicBlockMapper((int block) -> { int mappedIndex = map.get(block); return mappedIndex == 0 ? block : mappedIndex - 1; }); for (int copy : copies) { copyBlockMapper.transform(program.basicBlockAt(copy)); } for (int domainNode : domain) { copyBlockMapper.transform(program.basicBlockAt(domainNode)); } return copies; } }
@Override public int[] split(int[] domain, int[] nodes) { int[] copies = new int[nodes.length]; IntIntMap map = new IntIntHashMap(); for (int i = 0; i < nodes.length; ++i) { copies[i] = index++;
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static IntIntHashMap from(int[] keys, int[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } IntIntHashMap map = new IntIntHashMap(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
public IntIntHashMap(int initialCapacity) { g_map = new com.carrotsearch.hppc.IntIntHashMap(initialCapacity); }
public IntIntHashMap() { g_map = new com.carrotsearch.hppc.IntIntHashMap(); }
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { List<IntIntPair> list = (List<IntIntPair>)in.readObject(); g_map = new com.carrotsearch.hppc.IntIntHashMap(list.size()); putAll(list); }
private final IntIntHashMap team = new IntIntHashMap(); boolean found = team.value().containsMatch(new IntPredicate() { public boolean is(int score) { return score >= VICTORY_SCORE; } });
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static IntIntHashMap from(int[] keys, int[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } IntIntHashMap map = new IntIntHashMap(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * Calculate the size of "right language" for each state in an FSA. The right * language is the number of sequences encoded from a given node in the automaton. * * @param fsa The automaton to calculate right language for. * @return Returns a map with node identifiers as keys and their right language * counts as associated values. */ public static IntIntHashMap rightLanguageForAllStates(final FSA fsa) { final IntIntHashMap numbers = new IntIntHashMap(); fsa.visitInPostOrder(new StateVisitor() { public boolean accept(int state) { int thisNodeNumber = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) { thisNodeNumber += (fsa.isArcFinal(arc) ? 1 : 0) + (fsa.isArcTerminal(arc) ? 0 : numbers.get(fsa.getEndNode(arc))); } numbers.put(state, thisNodeNumber); return true; } }); return numbers; } }
/** * Calculate the size of "right language" for each state in an FSA. The right * language is the number of sequences encoded from a given node in the automaton. * * @param fsa The automaton to calculate right language for. * @return Returns a map with node identifiers as keys and their right language * counts as associated values. */ public static IntIntHashMap rightLanguageForAllStates(final FSA fsa) { final IntIntHashMap numbers = new IntIntHashMap(); fsa.visitInPostOrder(new StateVisitor() { public boolean accept(int state) { int thisNodeNumber = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) { thisNodeNumber += (fsa.isArcFinal(arc) ? 1 : 0) + (fsa.isArcTerminal(arc) ? 0 : numbers.get(fsa.getEndNode(arc))); } numbers.put(state, thisNodeNumber); return true; } }); return numbers; } }
public ProjectPushInfo(List<SchemaPath> columns, ImmutableList<DesiredField> desiredFields, ImmutableList<RexNode> inputRefs) { super(); this.columns = columns; this.desiredFields = desiredFields; this.inputsRefs = inputRefs; this.fieldNames = Lists.newArrayListWithCapacity(desiredFields.size()); this.types = Lists.newArrayListWithCapacity(desiredFields.size()); IntIntHashMap oldToNewIds = new IntIntHashMap(); int i =0; for (DesiredField f : desiredFields) { fieldNames.add(f.name); types.add(f.field.getType()); oldToNewIds.put(f.origIndex, i); i++; } this.rewriter = new InputRewriter(oldToNewIds); }
@Override public void setup(final int[] keys, final float fillFactor, int oneFailOutOf ) { super.setup( keys, fillFactor, oneFailOutOf ); m_map = new IntIntHashMap( keys.length, fillFactor ); for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key ); }
/** * Merge data from one or more sparse arrays. */ public static int [] mergeSparseArrays(Iterable<int []> source) { final IntIntHashMap m = new IntIntHashMap(); for (int[] list : source) { final int max = list.length; for (int i = 0; i < max; i += 2) { final int v = list[i + 1]; m.putOrAdd(list[i], v, v); } } return hashToKeyValuePairs(m); }
/** * Assigns documents to cluster labels. */ void assignDocuments(LingoProcessingContext context) { final int [] clusterLabelFeatureIndex = context.clusterLabelFeatureIndex; final BitSet [] clusterDocuments = new BitSet [clusterLabelFeatureIndex.length]; final int [] labelsFeatureIndex = context.preprocessingContext.allLabels.featureIndex; final BitSet [] documentIndices = context.preprocessingContext.allLabels.documentIndices; final IntIntHashMap featureValueToIndex = new IntIntHashMap(); for (int i = 0; i < labelsFeatureIndex.length; i++) { featureValueToIndex.put(labelsFeatureIndex[i], i); } for (int clusterIndex = 0; clusterIndex < clusterDocuments.length; clusterIndex++) { clusterDocuments[clusterIndex] = documentIndices[featureValueToIndex .get(clusterLabelFeatureIndex[clusterIndex])]; } context.clusterDocuments = clusterDocuments; }
@Override public int test() { final IntIntHashMap m_map = new IntIntHashMap( m_keys.length, m_fillFactor ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ],m_keys[ i ] ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ],m_keys[ i ] ); return m_map.size(); } }
/** * Convert to sparse encoding using a hash map. */ public static int [] toSparseEncodingByHash(IntStack documents) { final IntIntHashMap map = new IntIntHashMap(); final int toIndex = documents.size(); final int [] buffer = documents.buffer; for (int i = 0; i < toIndex; i++) { map.putOrAdd(buffer[i], 1, 1); } return hashToKeyValuePairs(map); }
@Override public int test() { final IntIntHashMap m_map = new IntIntHashMap( m_keys.length / 2 + 1, m_fillFactor ); int add = 0, remove = 0; while ( add < m_keys.length ) { m_map.put( m_keys[ add ], m_keys[ add ] ); ++add; m_map.put( m_keys[ add ], m_keys[ add ] ); ++add; m_map.remove( m_keys[ remove++ ] ); } return m_map.size(); } }
/** * Compute in-link count for each state. */ private IntIntHashMap computeInlinkCount(final FSA fsa) { IntIntHashMap inlinkCount = new IntIntHashMap(); BitSet visited = new BitSet(); IntStack nodes = new IntStack(); nodes.push(fsa.getRootNode()); while (!nodes.isEmpty()) { final int node = nodes.pop(); if (visited.get(node)) continue; visited.set(node); for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (!fsa.isArcTerminal(arc)) { final int target = fsa.getEndNode(arc); inlinkCount.putOrAdd(target, 1, 1); if (!visited.get(target)) nodes.push(target); } } } return inlinkCount; }
/** * Compute in-link count for each state. */ private IntIntHashMap computeInlinkCount(final FSA fsa) { IntIntHashMap inlinkCount = new IntIntHashMap(); BitSet visited = new BitSet(); IntStack nodes = new IntStack(); nodes.push(fsa.getRootNode()); while (!nodes.isEmpty()) { final int node = nodes.pop(); if (visited.get(node)) continue; visited.set(node); for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (!fsa.isArcTerminal(arc)) { final int target = fsa.getEndNode(arc); inlinkCount.putOrAdd(target, 1, 1); if (!visited.get(target)) nodes.push(target); } } } return inlinkCount; }