Refine search
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { SwitchPayload instr = (SwitchPayload) location.getInstruction(); TIntIntMap targetKeyToOffset = new TIntIntHashMap(); for (SwitchElement element : instr.getSwitchElements()) { targetKeyToOffset.put(element.getKey(), element.getOffset()); } return new SwitchPayloadOp(location, addressToLocation, targetKeyToOffset); }
public int lookupIndex(int code, int indent) { if (indent < 1) throw new IllegalArgumentException( "Invalid Argument in FeatureAlphabet: " + indent); int ret = intdata.get(code); if (ret==-1 && !frozen) {//字典中没有,并且允许插入 synchronized (this) { intdata.put(code, last); ret = last; last += indent; } } return ret; }
/** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof Integer ) { int ele = ( ( Integer ) element ).intValue(); if ( ! TIntIntHashMap.this.containsKey( ele ) ) { return false; } } else { return false; } } return true; }
/** {@inheritDoc} */ public void putAll( Map<? extends Integer, ? extends Integer> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Integer, ? extends Integer> entry : map.entrySet() ) { this.put( entry.getKey().intValue(), entry.getValue().intValue() ); } }
public int remove(String s) { String str = checkKeyMap(s); int code = hashcode.hashcode(str); int ret = -1; if (intdata.containsKey(code)) { ret = intdata.remove(code); } return ret; }
List<TripPattern> patternForIndex = Lists.newArrayList(totalPatterns); TObjectIntMap<TripPattern> indexForPattern = new TObjectIntHashMap<>(totalPatterns, 0.75f, -1); indexForStop = new TIntIntHashMap(totalStops, 0.75f, Integer.MIN_VALUE, -1); TIntList stopForIndex = new TIntArrayList(totalStops, Integer.MIN_VALUE); for (Stop stop : pattern.getStops()) { int vidx = graph.index.stopVertexForStop.get(stop).getIndex(); int stopIndex = indexForStop.get(vidx); if (stopIndex == -1) { stopIndex = indexForStop.size(); indexForStop.put(vidx, stopIndex); stopForIndex.add(vidx); stopNames.add(stop.getName()); 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; TIntIntMap transfersFromStopWithGraphIndices = new TIntIntHashMap(); for (TIntIntIterator trIt = transfersFromStop.iterator(); trIt.hasNext();) { temporaryTransfers.put(graphIndex, new TIntIntHashMap()); TIntIntMap out = new TIntIntHashMap();
/** * Increment the count for featureId. */ public synchronized void countFeature(int featureId) { synchronized (featureCounts) { if (!featureCounts.containsKey(featureId)) featureCounts.put(featureId, 1); else featureCounts.put(featureId, featureCounts.get(featureId) + 1); } }
TIntIntHashMap index = new TIntIntHashMap(); TIntIntIterator it = feature.iterator(); while (it.hasNext()) { int value = it.key(); int key = it.value(); index.put(key, value); int[] idx = index.keys(); Arrays.sort(idx); int length = weights.length; int str = index.get(base); int id = newfeat.lookupIndex(str, interv); for (int j = 0; j < interv; j++) { index.clear(); ww.clear();
/** {@inheritDoc} */ public void putAll( TIntIntMap map ) { ensureCapacity( map.size() ); TIntIntIterator iter = map.iterator(); while ( iter.hasNext() ) { iter.advance(); this.put( iter.key(), iter.value() ); } }
private void calculateCollisionAndDiffs() { TIntIntHashMap lastactivesegment = new TIntIntHashMap(); lastactivesegment.put(lastSplitCalc, lastActiveSegment); lastSplitCalc = segment.splitNo; lastActiveSegment = lastactivesegment.get(splitParents.get(segment.splitNo)); splitResistance = lastActiveSegment < segment.segmentNo ? 50 : 0; lastActiveSegment = segment.segmentNo; lastactivesegment.put(lastSplitCalc, lastActiveSegment); lastActiveSegment = lastactivesegment.get(0); for(Iterator<FXLightningSegment> iterator = segments.iterator(); iterator.hasNext();) { FXLightningSegment segment = iterator.next(); if(lastSplitCalc != segment.splitNo) { lastSplitCalc = segment.splitNo; lastActiveSegment = lastactivesegment.get(segment.splitNo);
TIntIntMap accessTimes = new TIntIntHashMap(); int stopIndex = indexForStop.get(tstop.getIndex()); accessTimes.put(stopIndex, (int) s.getElapsedTimeSeconds()); else accessTimes.put(stopIndex, (int) (s.getWalkDistance() / walkSpeed));
public HashFeatureAlphabet() { intdata = new TIntIntHashMap(DEFAULT_CAPACITY,DEFAULT_LOAD_FACTOR,noEntryValue,noEntryValue); frozen = false; last = 0; }
TIntIntMap initialStops = new TIntIntHashMap(); TIntIntIterator initialIterator = accessTimes.iterator(); while (initialIterator.hasNext()) { initialIterator.advance(); int stopIndex = initialIterator.key(); int accessTime = initialIterator.value(); initialStops.put(stopIndex, accessTime);
@Override public SparseIntArray reverse() { //TODO: this could be more efficient and avoid the copy TIntIntHashMap tmp = new TIntIntHashMap(data.size()); for (Entry e : entries()) tmp.put(length - e.index, e.value); this.data = tmp; return this; } }
private static Propagator createProp(IntVar[] vars, int[] values, IntVar[] cards) { assert values.length == cards.length; TIntIntHashMap map = new TIntIntHashMap(); int idx = 0; for (int v : values) { if (!map.containsKey(v)) { map.put(v, idx); idx++; } else { throw new UnsupportedOperationException("ERROR: multiple occurrences of value: " + v); } } return new PropFastGCC(vars, values, map, cards); }
TIntIntHashMap diffF = new TIntIntHashMap(); // 最多有2*L*numTemplets个不同 int pI = data[l][t] + templets.offset[t][pS]; // 特征索引:找到对应weights的维数 if (tI != pI) { diffF.adjustOrPutValue(tI, 1, 1); diffF.adjustOrPutValue(pI, -1, -1); TIntIntIterator it = diffF.iterator(); for (int i = diffF.size(); i-- > 0;) { it.advance(); diff += it.value() * it.value(); it = diffF.iterator(); for (int i = diffF.size(); i-- > 0;) { it.advance(); weights[it.key()] += it.value() * alpha;
@Override public <O, A> void train(List<? extends Annotated<O, A>> data) { TIntIntHashMap nAnnotationCounts = new TIntIntHashMap(); int maxVal = 0; for (Annotated<O, A> sample : data) { Collection<A> annos = sample.getAnnotations(); nAnnotationCounts.adjustOrPutValue(annos.size(), 1, 1); if (annos.size()>maxVal) maxVal = annos.size(); } //build distribution and rng for the number of annotations double [] distr = new double[maxVal+1]; for (int i=0; i<=maxVal; i++) distr[i] = nAnnotationCounts.get(i); numAnnotations = new EmpiricalWalker(distr, Empirical.NO_INTERPOLATION, new MersenneTwister()); }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TIntIntMap ) ) { return false; } TIntIntMap that = ( TIntIntMap ) other; if ( that.size() != this.size() ) { return false; } int[] values = _values; byte[] states = _states; int this_no_entry_value = getNoEntryValue(); int that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { int key = _set[i]; int that_value = that.get( key ); int this_value = values[i]; if ( ( this_value != that_value ) && ( this_value != this_no_entry_value ) && ( that_value != that_no_entry_value ) ) { return false; } } } return true; }
TIntIntMap assigned = new TIntIntHashMap(); TinkersItem tool = (TinkersItem) toolStack.getItem(); if(!assigned.valueCollection().contains(j)) { candidate = j; return ItemStack.EMPTY; assigned.put(i, candidate); if(assigned.isEmpty()) { return ItemStack.EMPTY;