private int getUniformLocation(int activeShaderProgramId, String desc) { UniformId id = new UniformId(activeShaderProgramId, desc); if (uniformLocationMap.containsKey(id)) { return uniformLocationMap.get(id); } int loc = GL20.glGetUniformLocation(activeShaderProgramId, desc); uniformLocationMap.put(id, loc); return loc; }
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
public Collection<TransitStop> getTouchedStopsIncludingTransfers () { return matrix[current].keySet(); } }
private int getTileIndex(ResourceUrn uri, boolean warnOnError) { if (tileIndexes.containsKey(uri)) { return tileIndexes.get(uri); } if (warnOnError) { logger.warn("Tile {} could not be resolved", uri); } return 0; }
@Override public boolean put(TransitStop t, int time, boolean transfer) { // This does not store internal algorithm state as it used to, but rather only the output. // The reasoning is that, in dynamic programming/range RAPTOR mode, bestStops is carried over between runs of // the algorithm. But you still want to propagate a non-optimal time with fewer transfers, because the // optimal time at this stop might have already used up all of the transfers. if (!transfer && time < bestStops.get(t)) bestStops.put(t, time); if (time < matrix[current].get(t)) { matrix[current].put(t, time); return true; } return false; }
if ( that.size() != this.size() ) { return false; int value = iter.value(); if ( value == no_entry_value ) { if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) { if ( value != that.get( key ) ) { return false;
@Override public final synchronized long getCounter(String task) { return taskCounters.get(task); }
/** * Build the ID - Index map if needed. */ private synchronized void buildIdIndexMapIfNeeded () { // we check again if the map has been built. It's possible that it would have been built // by this method in another thread while this instantiation was blocked. if (idIndexMap == null) { // make a local object, don't expose to public view until it's built TObjectIntMap idIndexMap = new TObjectIntHashMap<String>(this.capacity, 1f, -1); for (int i = 0; i < this.capacity; i++) { if (ids[i] != null) { if (idIndexMap.containsKey(ids[i])) { LOG.error("Duplicate ID {} in pointset.", ids[i]); } else { idIndexMap.put(ids[i], i); } } } // now expose to public view; reference assignment is an atomic operation this.idIndexMap = idIndexMap; } }
@Override public final int replace(String existing, String replacement) { final int index = indexMap.remove(existing); if (index == -1) { throw new IndexException("No match key for " + existing); } else { if (indexMap.containsKey(replacement)) { throw new IndexException("The replacement key already exists in index " + replacement); } else { final int ordinal = getOrdinalForIndex(index); this.indexMap.put(replacement, index); this.keyArray().setValue(ordinal, replacement); return index; } } }
public int put( K key, int value ) { synchronized( mutex ) { return m.put( key, value ); } } public int remove( Object key ) {
private void calculateHungerSaturationAndRemoveOptionals(Recipe recipe, List<IngredientStack> optionals) { float hunger = 0; float saturation = 0F; TObjectIntMap<Ingredient> added = new TObjectIntHashMap<>(); for (IngredientStack stack: optionals) { Ingredient main = stack.getIngredient(); //If we haven't already added this ingredient, use the full value if (!added.containsKey(main) || stack.isSame(required)) { hunger += main.getHunger(); saturation += main.getSaturation(); added.put(main, 0); } else { //If we have already used this ingredient, let's get how many times we have int used = added.adjustOrPutValue(main, 1, 1); hunger += (((double)main.getHunger())/ (4 * used)); saturation += ((main.getSaturation())/ (4 * used)); //We're added less and less each time to hunger and saturation for each ingredient } if (added.size() >= recipe.getMaximumOptionalIngredients()) break; } this.optional.clear(); this.hunger = (int) Math.floor(hunger); this.saturation = saturation; }
private void calculateActualHungerAndSaturationValues(Recipe recipe) { //Add the leftover required ingredients if (required.size() > 0) { TObjectIntMap<Ingredient> added = new TObjectIntHashMap<>(); for (IngredientStack stack: required) { Ingredient main = stack.getIngredient(); //If we haven't already added this ingredient, use the full value if (!added.containsKey(main)) { hunger += (main.getHunger() / 2); saturation += (main.getSaturation() / 2); added.put(main, 0); } else { //If we have already used this ingredient, let's get how many times we have int used = added.adjustOrPutValue(main, 1, 1); hunger += (((double)main.getHunger())/ (4 * used)); saturation += ((main.getSaturation())/ (4 * used)); //We're added less and less each time to hunger and saturation for each ingredient } } } this.hunger = recipe.getHunger() + (int)((double)this.hunger / stackSize); this.saturation = recipe.getSaturation() + (this.saturation / stackSize); }
@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(); } }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Integer</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Integer put( K key, Integer value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
/** * Empties the map. */ public void clear() { this._map.clear(); }
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey( Object key ) { return _map.containsKey( key ); }
public int remove( Object key ) { synchronized( mutex ) { return m.remove( key ); } } public void putAll( Map<? extends K, ? extends Integer> map ) {