Java Code Examples for gnu.trove.map.TObjectIntMap#put()
The following examples show how to use
gnu.trove.map.TObjectIntMap#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: AbstractAttributeClustering.java From JedAIToolkit with Apache License 2.0 | 6 votes |
protected AttributeClusters clusterAttributes(int datasetId, ConnectedComponents cc) { int firstId = datasetId == DATASET_1 ? 0 : attributesDelimiter; int lastId = 0 < attributesDelimiter && datasetId == DATASET_1 ? attributesDelimiter : noOfAttributes; int glueClusterId = cc.count() + 1; int[] clusterFrequency = new int[glueClusterId + 1]; float[] clusterEntropy = new float[glueClusterId + 1]; final TObjectIntMap<String> clusters = new TObjectIntHashMap<>(); for (int i = firstId; i < lastId; i++) { int ccId = cc.id(i); if (cc.size(i) == 1) { // singleton attribute ccId = glueClusterId; } clusterFrequency[ccId]++; clusterEntropy[ccId] += attributeModels[datasetId][i].getEntropy(true); clusters.put(attributeModels[datasetId][i].getInstanceName(), ccId); } for (int i = 0; i < glueClusterId + 1; i++) { clusterEntropy[i] /= clusterFrequency[i]; } return new AttributeClusters(clusterEntropy, clusters); }
Example 2
Source File: FuzzySetSimJoin.java From JedAIToolkit with Apache License 2.0 | 5 votes |
int[][][] transform(Map<String, List<Set<String>>> input, TObjectIntMap<String> tokenDictionary) { int[][][] collection = new int[input.size()][][]; boolean existingDictionary = tokenDictionary.size() > 0; int unknownTokenCounter = 0; int i = 0, j, k; List<Set<String>> elements; for (String set : input.keySet()) { elements = input.get(set); collection[i] = new int[elements.size()][]; j = 0; for (Set<String> element : elements) { collection[i][j] = new int[element.size()]; k = 0; for (String token : element) { if (!tokenDictionary.containsKey(token)) { if (existingDictionary) { unknownTokenCounter--; tokenDictionary.put(token, unknownTokenCounter); } else { tokenDictionary.put(token, tokenDictionary.size()); } } collection[i][j][k] = tokenDictionary.get(token); k++; } j++; } i++; } return collection; }
Example 3
Source File: TroveObjectIntMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TObjectIntMap<Integer> m_map = new TObjectIntHashMap<>( m_keys.length, m_fillFactor ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ], i ); for ( int i = 0; i < m_keys2.length; ++i ) m_map.put( m_keys2[ i ], i ); return m_map.size(); }
Example 4
Source File: TroveObjectIntMapTest.java From hashmapTest with The Unlicense | 5 votes |
@Override public int test() { final TObjectIntMap<Integer> m_map = new TObjectIntHashMap<>( m_keys.length / 2 + 1, m_fillFactor ); int add = 0, remove = 0; while ( add < m_keys.length ) { m_map.put( m_keys[ add ], add ); ++add; m_map.put( m_keys[ add ], add ); ++add; m_map.remove( m_keys[ remove++ ] ); } return m_map.size(); }
Example 5
Source File: UpgradeKilling.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void update(IUpgradableBlock chest, ItemStack stack) { if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 100) != 0) { return; } AxisAlignedBB bb = new AxisAlignedBB(chest.getPosition()).grow(RADIUS); TObjectIntMap<Class<? extends EntityLiving>> map = new TObjectIntHashMap<>(); for (EntityLiving entity : chest.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, bb)) { if (entity.isDead) { continue; } if (entity instanceof EntityAnimal) { EntityAnimal animal = (EntityAnimal) entity; if (entity.isChild()) { continue; } int currentAnimals = map.get(animal.getClass()); if (currentAnimals < ANIMALS_TO_KEEP_ALIVE) { map.put(animal.getClass(), currentAnimals + 1); continue; } } if (hasUpgradeOperationCost(chest)) { EntityPlayer source = null; if (chest.isUpgradeInstalled(DummyUpgradeType.AI.getStack())) { source = chest.getFakePlayer(); } entity.attackEntityFrom(getDamageSource(source), 10); drawUpgradeOperationCode(chest); } } }