public static ViewDistance forIndex(int viewDistanceLevel) { ViewDistance result = indexLookup.get(viewDistanceLevel); if (result == null) { return LEGALLY_BLIND; } return result; }
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
/** * 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 ) { if ( key == null ) return _map.containsKey( _map.getNoEntryKey() ); return key instanceof Integer && _map.containsKey( ( ( Integer ) key ).intValue() ); }
/** * Creates a new <code>TIntObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TIntObjectMap</tt> to be copied. */ public TIntObjectHashMap( TIntObjectMap<? extends V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or Integer(0) if it was not found in the map */ public V remove( Object key ) { int k; if ( key != null ) { if ( key instanceof Integer ) { k = unwrapKey( ( Integer ) key ); } else { return null; } } else { k = _map.getNoEntryKey(); } return _map.remove( k ); }
} catch (VertexNotFoundException vnfe) { LOG.warn("Temporary stop at {}, {} not connected to graph", t.lat, t.lon); temporaryStopTreeCache.put(t.index, new int[0]); temporaryTransfers.put(t.index, new TIntIntHashMap()); continue; temporaryStopTreeCache.put(t.index, distances); temporaryTransfers.put(t.index, transfersFromStopWithGraphIndices); if (!temporaryTransfers.containsKey(graphIndex)) temporaryTransfers.put(graphIndex, new TIntIntHashMap()); temporaryTransfers.get(graphIndex).put(t.index, it.value()); for (int pattern = 0; pattern < timetablesForPattern.size(); pattern++) { for (int stop : timetablesForPattern.get(pattern).stopIndices) { if (!patternsForStopList.containsKey(stop)) patternsForStopList.put(stop, new TIntArrayList()); patternsForStopList.get(stop).add(pattern); for (int stop = 0; patternsForStopList.containsKey(stop); stop++) { patternsForStop.add(patternsForStopList.get(stop).toArray()); if (temporaryTransfers.containsKey(stop)) { for (TIntIntIterator tranIt = temporaryTransfers.get(stop).iterator(); tranIt.hasNext();) { tranIt.advance();
@Test public void shiftIntegerMapKeysShiftsUpAsExpected() { TIntObjectMap<String> intToObject = new TIntObjectHashMap<String>(); intToObject.put(1, "one"); intToObject.put(2, "two"); intToObject.put(3, "three"); Utils.shiftIntegerMapKeys(1, 2, intToObject); assertEquals(3, intToObject.size()); assertEquals("one", intToObject.get(1)); assertEquals("two", intToObject.get(4)); assertEquals("three", intToObject.get(5)); }
public static <T> void shiftIntegerMapKeys(int startKey, int shift, TIntObjectMap<T> intToObject) { if (shift == 0) { return; } TIntList keysToShift = new TIntArrayList(intToObject.keys()); // Exclude anything before and including startKey for (int currentKey : keysToShift.toArray()) { if (currentKey <= startKey) { keysToShift.remove(currentKey); } } keysToShift.sort(); if (shift > 0) { // Shifting keys up, so start at the end to avoid overwriting keys. keysToShift.reverse(); } for (int currentKey : keysToShift.toArray()) { T obj = intToObject.get(currentKey); intToObject.remove(currentKey); intToObject.put(currentKey + shift, obj); } } }
/** * Returns a key based on the provided key Id. * @param id The id of the key. * @return The key with this id. */ public static Input find(int id) { Input result = lookupById.get(id); if (result == null) { result = new UnknownInput(InputType.KEY, id); lookupById.put(id, result); lookupByName.put(result.getName(), result); } return result; } }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( ! ( other instanceof TIntObjectMap ) ) { return false; } TIntObjectMap that = ( TIntObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TIntObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); int key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
if (!raptorData.transferRules.isEmpty() && raptorData.transferRules.containsKey(stopIndex)) { for (TransferRule tr : raptorData.transferRules.get(stopIndex)) { if (tr.matches(raptorData.timetablesForPattern.get(previousPattern), this)) { transferRule = tr; int minTime = startTimes[trip] + timeToReachStop + offsets.offsets.get(this.dataIndex)[trip];
public String[] get(int vecid) { if (this.sorters.containsKey(vecid)) { return this.sorters.get(vecid).pickle(); } else return new String[0]; }
private void processDeletedEvt(int tgtVecId) { if (this.reverseIndexer.containsKey(tgtVecId)) { TIntSet range = this.reverseIndexer.get(tgtVecId); TIntIterator iter = range.iterator(); while (iter.hasNext()) { int srcVecId = iter.next(); this.sorters.get(srcVecId).remove(tgtVecId); } } reverseIndexer.remove(tgtVecId); }
if (!decodingRules.containsKey(id)) { decodingRules.put(id, new TagValuePair(tag, val, type));
private ProtocolData getProtocolData(int version) { ProtocolData protocol = protocols.get( version ); if ( protocol == null && ( protocolPhase != Protocol.GAME ) ) { protocol = Iterables.getFirst( protocols.valueCollection(), null ); } return protocol; }
/** * Marks the specified priority request as completed, and returns the suspended Response object for the connection * that submitted the priority request (the UI), which probably still waiting to receive a result back over the * same connection. A HttpHandler thread can then pump data from the DELETE body back to the origin of the request, * without blocking the broker thread. * TODO rename to "deregisterSuspendedProducer" and "deregisterSuspendedConsumer" ? */ public synchronized Response deletePriorityTask (int taskId) { return highPriorityResponses.remove(taskId); }
/** * Empties the map. */ public void clear() { this._map.clear(); }