本文整理了Java中gnu.trove.map.TObjectIntMap
类的一些代码示例,展示了TObjectIntMap
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TObjectIntMap
类的具体详情如下:
包路径:gnu.trove.map.TObjectIntMap
类名称:TObjectIntMap
[英]Interface for a primitive map of Object keys and int values.
[中]用于对象键和int值的基本映射的接口。
代码示例来源:origin: MovingBlocks/Terasology
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;
}
代码示例来源:origin: alibaba/mdrill
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public Collection<TransitStop> getTouchedStopsIncludingTransfers () {
return matrix[current].keySet();
}
}
代码示例来源:origin: MovingBlocks/Terasology
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;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
@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;
}
代码示例来源:origin: alibaba/mdrill
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;
代码示例来源:origin: MovingBlocks/Terasology
@Override
public final synchronized long getCounter(String task) {
return taskCounters.get(task);
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
@Override
public void proceed() {
for (TObjectIntIterator<TransitStop> it = matrix[current].iterator(); it.hasNext();) {
it.advance();
if (it.value() < matrix[current + 1].get(it.key()))
matrix[current + 1].put(it.key(), it.value());
}
current++;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
/**
* 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;
}
}
代码示例来源:origin: zavtech/morpheus-core
@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;
}
}
}
代码示例来源:origin: alibaba/mdrill
public int put( K key, int value ) {
synchronized( mutex ) { return m.put( key, value ); }
}
public int remove( Object key ) {
代码示例来源:origin: PenguinSquad/Harvest-Festival
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;
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
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);
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
for (Stop stop : fromStops.keySet()) {
times.set(stop, fromStops.get(stop));
Set<Stop> stopsUpdated = fromStops.keySet();
for (TObjectIntIterator<Vertex> iter = distanceToVertex.iterator(); iter.hasNext(); ) {
iter.advance();
Vertex vertex = iter.key();
代码示例来源:origin: mikvor/hashmapTest
@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();
}
}
代码示例来源:origin: alibaba/mdrill
/**
* 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 ) ) );
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
indexForPattern.put(pattern, patternForIndex.size());
patternForIndex.add(pattern);
patternNames.add(pattern.code);
addedStops.put(t, stopIndex);
indexForStop.put(t.index, stopIndex);
stopForIndex.add(t.index);
for (AddTripPattern.TemporaryStop t : addedStops.keySet()) {
代码示例来源:origin: alibaba/mdrill
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
代码示例来源:origin: alibaba/mdrill
/**
* 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 );
}
代码示例来源:origin: alibaba/mdrill
public int remove( Object key ) {
synchronized( mutex ) { return m.remove( key ); }
}
public void putAll( Map<? extends K, ? extends Integer> map ) {
内容来源于网络,如有侵权,请联系作者删除!