Java Code Examples for gnu.trove.map.TIntObjectMap#put()
The following examples show how to use
gnu.trove.map.TIntObjectMap#put() .
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: PoolTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testTroveMapPreservesSynapseOrdering() { Synapse s = new Synapse(); TIntObjectMap<Synapse> t = new TIntObjectHashMap<>(); t.put(2, s); t.put(4, s); t.put(6, s); t.put(8, s); t.put(10, s); t.put(12, s); int[] expectedKeys = { 12, 10, 8, 6, 4, 2 }; assertTrue(Arrays.equals(expectedKeys, t.keys())); // Insert a cell index in the middle, check that order is still // preserved following inserts t.put(3, s); expectedKeys = new int[] { 12, 10, 8, 6, 4, 3, 2 }; assertTrue(Arrays.equals(expectedKeys, t.keys())); // Check reversing produces ascending ordered Synapses expectedKeys = new int[] { 2, 3, 4, 6, 8, 10, 12 }; assertTrue(Arrays.equals(expectedKeys, ArrayUtils.reverse(t.keys()))); }
Example 2
Source File: StaticRoutingConverter.java From scheduler with GNU Lesser General Public License v3.0 | 6 votes |
@Override public StaticRouting fromJSON(Model mo, JSONObject o) throws JSONConverterException { Network v = Network.get(mo); TIntObjectMap<Link> idToLink = new TIntObjectHashMap<>(); for (Link l : v.getLinks()) { idToLink.put(l.id(), l); } StaticRouting r = new StaticRouting(); checkKeys(o, ROUTES_LABEL); JSONArray a = (JSONArray) o.get(ROUTES_LABEL); for (Object ao : a) { StaticRouting.NodesMap nm = nodesMapFromJSON(mo, (JSONObject) ((JSONObject) ao).get("nodes_map")); Map<Link, Boolean> links = new LinkedHashMap<>(); JSONArray aoa = (JSONArray) ((JSONObject) ao).get("links"); for (Object aoao : aoa) { links.put(idToLink.get(requiredInt((JSONObject)aoao, "link")), Boolean.valueOf(requiredString((JSONObject) aoao, "direction"))); } r.setStaticRoute(nm, links); } return r; }
Example 3
Source File: PipeGridElementWidget.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private static TIntObjectMap<TextureHolder> initializeIcons(Map<TextureSprite, TextureArea> sprite2TextureMap) { TIntObjectMap<TextureHolder> resultMap = new TIntObjectHashMap<>(); for (int i = 0; i < 4; i++) { resultMap.put(pack(i, i + 1), new TextureHolder(sprite2TextureMap.get(TextureSprite.EDGE), i)); resultMap.put(pack(i, i + 1, i + 2), new TextureHolder(sprite2TextureMap.get(TextureSprite.T_JOINT), i)); } for (int i = 0; i < 2; i++) { resultMap.put(pack(i, i + 2), new TextureHolder(sprite2TextureMap.get(TextureSprite.STRAIGHT), i)); resultMap.put(pack(i), new TextureHolder(sprite2TextureMap.get(TextureSprite.STRAIGHT), i)); resultMap.put(pack(i + 2), new TextureHolder(sprite2TextureMap.get(TextureSprite.STRAIGHT), i)); } resultMap.put(pack(0, 1, 2, 3), new TextureHolder(sprite2TextureMap.get(TextureSprite.CROSS), 0)); return resultMap; }
Example 4
Source File: TroveIntObjectMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TIntObjectMap<Integer> m_map = new TIntObjectHashMap<>( m_keys.length, m_fillFactor ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ], null ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ], null ); return m_map.size(); }
Example 5
Source File: TroveIntObjectMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TIntObjectMap<Integer> m_map = new TIntObjectHashMap<>( m_keys.length / 2 + 1, m_fillFactor ); final Integer value = 1; int add = 0, remove = 0; while ( add < m_keys.length ) { m_map.put( m_keys[ add ], value ); ++add; m_map.put( m_keys[ add ], value ); ++add; m_map.remove( m_keys[ remove++ ] ); } return m_map.size(); }
Example 6
Source File: ChrPosMap.java From systemsgenetics with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("RedundantStringConstructorCall") public void put(String chr, int pos, E element){ TIntObjectMap<E> chrElements = data.get(chr); if(chrElements == null){ chrElements = new TIntObjectHashMap<E>(); data.put(new String(chr), chrElements); } chrElements.put(pos, element); }
Example 7
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 8
Source File: DataWatcherTransformer.java From Carbon-2 with GNU Lesser General Public License v3.0 | 4 votes |
private static void moveDWData(TIntObjectMap<DataWatcherObject> from, TIntObjectMap<DataWatcherObject> to, int oldId, int newId) { DataWatcherObject dwobject = from.remove(oldId); if (dwobject != null) { to.put(newId, dwobject); } }
Example 9
Source File: DataWatcherTransformer.java From Carbon-2 with GNU Lesser General Public License v3.0 | 4 votes |
private static void moveDWData(TIntObjectMap<DataWatcherObject> from, TIntObjectMap<DataWatcherObject> to, int oldId, int newId) { DataWatcherObject dwobject = from.remove(oldId); if (dwobject != null) { to.put(newId, dwobject); } }