gnu.trove.map.TIntIntMap Java Examples
The following examples show how to use
gnu.trove.map.TIntIntMap.
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: IEJoin.java From metanome-algorithms with Apache License 2.0 | 5 votes |
private static int[] getPermutationArray(int[] l2, int[] l1) { final int count = l1.length; TIntIntMap map = new TIntIntHashMap(count); for (int i = 0; i < count; ++i) { map.put(l1[i], i); } int[] result = new int[count]; for (int i = 0; i < count; ++i) { result[i] = map.get(l2[i]); } return result; }
Example #2
Source File: TroveMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TIntIntMap m_map = new TIntIntHashMap( 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(); }
Example #3
Source File: TroveMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TIntIntMap m_map = new TIntIntHashMap( 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(); }
Example #4
Source File: MetricTable.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static mt_str encodeStr(TIntIntMap t_str, int timestampsSize) { LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_str)); int[] values = new int[timestampsSize]; int values_len = 0; for (int i = 0; i < values.length; ++i) { if (t_str.containsKey(i)) values[values_len++] = t_str.get(i); } mt_str result = new mt_str(); result.presence = createPresenceBitset(t_str.keySet(), timestampsSize); result.values = Arrays.copyOf(values, values_len); return result; }
Example #5
Source File: MetricTable.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static mt_32bit encode32Bit(TIntIntMap t_32bit, int timestampsSize) { LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_32bit)); int[] values = new int[timestampsSize]; int values_len = 0; for (int i = 0; i < values.length; ++i) { if (t_32bit.containsKey(i)) values[values_len++] = t_32bit.get(i); } mt_32bit result = new mt_32bit(); result.presence = createPresenceBitset(t_32bit.keySet(), timestampsSize); result.values = Arrays.copyOf(values, values_len); return result; }
Example #6
Source File: Utils.java From apkfile with Apache License 2.0 | 5 votes |
public static Map<Integer, Integer> convertToJava(TIntIntMap map) { Map<Integer, Integer> javaMap = new HashMap<>(); for (int key : map.keys()) { javaMap.put(key, map.get(key)); } return javaMap; }
Example #7
Source File: DexMethod.java From apkfile with Apache License 2.0 | 4 votes |
public TIntIntMap getOpCounts() { return opCounts; }
Example #8
Source File: LanguageModelContext.java From ambiverse-nlu with Apache License 2.0 | 4 votes |
public TIntIntMap getUnitCountsForEntity(Entity entity, UnitType unitType) { TIntObjectHashMap<TIntIntHashMap> curEntityUnitCounts = entityUnitCounts.get(unitType.ordinal()); if (curEntityUnitCounts == null) return new TIntIntHashMap(); TIntIntHashMap curUnitCounts = curEntityUnitCounts.get(entity.getId()); return curUnitCounts != null ? curUnitCounts : new TIntIntHashMap(); }
Example #9
Source File: Utils.java From apkfile with Apache License 2.0 | 4 votes |
public static void rollUp(TIntIntMap dest, TIntIntMap src) { for (int key : src.keys()) { int value = src.get(key); dest.adjustOrPutValue(key, value, value); } }
Example #10
Source File: MaterialCounter.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
private MaterialCounter(TIntIntMap counts) { this.counts = counts; }
Example #11
Source File: Input.java From metanome-algorithms with Apache License 2.0 | 4 votes |
public void buildPLIs() { long time = System.currentTimeMillis(); final int COLUMN_COUNT = parsedColumns.size(); final int ROW_COUNT = getLineCount(); List<Integer> tIDs = new TupleIDProvider(ROW_COUNT).gettIDs(); // to save integers storage int[][] inputs = getInts(); for (int col = 0; col < COLUMN_COUNT; ++col) { TIntSet distincts = new TIntHashSet(); for (int line = 0; line < ROW_COUNT; ++line) { distincts.add(inputs[line][col]); } int[] distinctsArray = distincts.toArray(); // need to sort for doubles and integers if (!(parsedColumns.get(col).getType() == String.class)) { Arrays.sort(distinctsArray);// ascending is the default } TIntIntMap translator = new TIntIntHashMap(); for (int position = 0; position < distinctsArray.length; position++) { translator.put(distinctsArray[position], position); } List<Set<Integer>> setPlis = new ArrayList<>(); for (int i = 0; i < distinctsArray.length; i++) { setPlis.add(new TreeSet<Integer>()); } for (int line = 0; line < ROW_COUNT; ++line) { Integer tid = tIDs.get(line); setPlis.get(translator.get(inputs[line][col])).add(tid); } int values[] = new int[ROW_COUNT]; for (int line = 0; line < ROW_COUNT; ++line) { values[line] = inputs[line][col]; } PLI pli; if (!(parsedColumns.get(col).getType() == String.class)) { pli = new PLI(setPlis, ROW_COUNT, true, values); } else { pli = new PLI(setPlis, ROW_COUNT, false, values); } parsedColumns.get(col).setPLI(pli); } log.info("Time to build plis: " + (System.currentTimeMillis() - time)); }
Example #12
Source File: MaterialCounter.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
private MaterialCounter(TIntIntMap counts) { this.counts = counts; }
Example #13
Source File: AllPairs.java From JedAIToolkit with Apache License 2.0 | 4 votes |
private List<Comparison> performJoin() { final List<Comparison> executedComparisons = new ArrayList<>(); final TIntObjectMap<ListItemPPJ> index = new TIntObjectHashMap<>(); for (int k = 0; k < noOfEntities; k++) { final TIntList record = records[k]; int minLength = minPossibleLength(record.size()); int probeLength = probeLength(record.size()); int indexLength = indexLength(record.size()); final int[] requireOverlaps = new int[record.size() + 1]; for (int l = minLength; l <= record.size(); l++) { requireOverlaps[l] = requireOverlap(record.size(), l); } final TIntIntMap occurances = new TIntIntHashMap(); for (int t = 0; t < probeLength; t++) { int token = record.get(t); ListItemPPJ item = index.get(token); if (item == null) { item = new ListItemPPJ(); index.put(token, item); } int pos = item.getPos(); final List<IntPair> ids = item.getIds(); int noOfIds = ids.size(); while (pos < noOfIds && records[ids.get(pos).getKey()].size() < minLength) { pos++; } for (int p = pos; p < noOfIds; p++) { int candId = ids.get(p).getKey(); int oldValue = occurances.get(candId); occurances.put(candId, (oldValue + 1)); } if (t < indexLength) { ids.add(new IntPair(k, t)); } } for (int cand : occurances.keys()) { if (k == cand) { continue; } if (isCleanCleanER) { if (originalId[k] < datasetDelimiter && originalId[cand] < datasetDelimiter) { // both belong to dataset 1 continue; } if (datasetDelimiter <= originalId[k] && datasetDelimiter <= originalId[cand]) { // both belong to dataset 2 continue; } } int noOfCandidates = records[cand].size(); int newindexLength = indexLength(noOfCandidates); if (records[cand].get(newindexLength - 1) < records[k].get(probeLength - 1)) { if (occurances.get(cand) + noOfCandidates - newindexLength < requireOverlaps[noOfCandidates]) { continue; } } else { if (occurances.get(cand) + records[k].size() - probeLength < requireOverlaps[noOfCandidates]) { continue; } } int realOverlap = getOverlap(k, cand, requireOverlaps[noOfCandidates]); if (realOverlap != -1) { float jaccardSim = calcSimilarity(records[k].size(), noOfCandidates, realOverlap); if (jaccardSim >= threshold) { final Comparison currentComp = getComparison(originalId[k], originalId[cand]); currentComp.setUtilityMeasure(jaccardSim); // is this correct? executedComparisons.add(currentComp); } } } } return executedComparisons; }
Example #14
Source File: LanguageModelMentionEntitySimilarityMeasure.java From ambiverse-nlu with Apache License 2.0 | 4 votes |
@Override public double calcSimilarity(Mention mention, Context context, Entity entity, EntitiesContext entitiesContext) throws EntityLinkingDataAccessException { if (!(entitiesContext instanceof LanguageModelContext)) { logger.warn("LanguageModelMentionEntitySimilarityMeasure#calcSimilarity() " + "was invoked with an EntitiesContext that's not a LanguageModelContext => " + "returning 0.0 as similarity"); return 0d; } LanguageModelContext languageModelContext = (LanguageModelContext) entitiesContext; if (originalInputText == null) { logger.debug("Calculating similarity, original input text is null."); originalInputText = new InputTextWrapper(context, unitType, removeStopwords); } if (languageModelContext.shouldIgnoreMention(unitType)) originalInputText.mentionToIgnore(mention); KLDivergenceCalculator klDivergenceCalculator = new KLDivergenceCalculator(normalized); TIntIntMap unitCountsForEntity = languageModelContext.getUnitCountsForEntity(entity, unitType); UnitMeasureTracer mt = null; if (isTracing) mt = new UnitMeasureTracer(getIdentifier(), 0.0, unitCountsForEntity.size()); int entityUnitsSum = 0; for (int unitCount : unitCountsForEntity.values()) { entityUnitsSum += unitCount; } int unitGlobalCount, unitEntityCount; for (int unit : originalInputText.getUnits()) { if (unit == 0) continue; unitGlobalCount = languageModelContext.getUnitCount(unit, unitType); unitEntityCount = unitCountsForEntity.get(unit); // this check makes sure that the unit exist for this unitType if (unitGlobalCount == 0) continue; double summand = -klDivergenceCalculator .addSummand(originalInputText.getUnitCount(unit), originalInputText.getSize(), unitEntityCount, entityUnitsSum, languageModelContext.getUnitCount(unit, unitType), languageModelContext.getCollectionSize(), languageModelContext.getSmoothingParameter(unitType)); if (mt != null) mt.addUnitTraceInfo(unit, summand, unitEntityCount != 0); } if (mt != null) { mt.setScore(-klDivergenceCalculator.getKLDivergence()); tracer.addMeasureForMentionEntity(mention, entity.getId(), mt); } return -klDivergenceCalculator.getKLDivergence(); }
Example #15
Source File: ExternalEntitiesContext.java From ambiverse-nlu with Apache License 2.0 | 4 votes |
public TIntIntMap getTransientWordExpansions() { return transientWordExpansions_; }
Example #16
Source File: TIntIntHashMap.java From baleen with Apache License 2.0 | 4 votes |
/** See {@link gnu.trove.map.hash.TIntIntHashMap#putAll(TIntIntMap)} */ public void putAll(TIntIntMap map) { delegate.putAll(map); }
Example #17
Source File: TileEntityPipeBase.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public TIntIntMap getBlockedConnectionsMap() { return new TIntIntHashMap(blockedConnectionsMap); }
Example #18
Source File: IPipeTile.java From GregTech with GNU Lesser General Public License v3.0 | votes |
TIntIntMap getBlockedConnectionsMap();