/** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectIntProcedure<K>() { private boolean first = true; public boolean execute( K key, int value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectIntHashMap
/** * See {@link * gnu.trove.map.hash.TObjectIntHashMap#forEachEntry(gnu.trove.procedure.TObjectIntProcedure)} */ public boolean forEachEntry(TObjectIntProcedure<? super K> procedure) { return delegate.forEachEntry(procedure::execute); }
public synchronized void forEachEntry(TObjectIntProcedure<IdentityIF> proc) { map.forEachEntry(proc); }
/** * See {@link * gnu.trove.map.hash.TObjectIntHashMap#forEachEntry(gnu.trove.procedure.TObjectIntProcedure)} */ public boolean forEachEntry(TObjectIntProcedure<? super K> procedure) { return delegate.forEachEntry(procedure::execute); }
@Override public boolean equals(Object other){ if(!(other instanceof TweetCountWordMap))return false; final TweetCountWordMap that = (TweetCountWordMap)other; boolean eq = this.ntweets == that.ntweets; if(!eq) return false; return this.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String arg0, int arg1) { return that.wordMap.get(arg0) == arg1; } }); } /**
@Override public boolean equals(Object other){ if(!(other instanceof TweetCountWordMap))return false; final TweetCountWordMap that = (TweetCountWordMap)other; boolean eq = this.ntweets == that.ntweets; if(!eq) return false; return this.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String arg0, int arg1) { return that.wordMap.get(arg0) == arg1; } }); } /**
/** * Add values from "that" to those in this if they exist, otherwise create the element * and start a new count * @param that */ public void combine(TweetCountWordMap that) { this.ntweets += that.ntweets; if(this.wordMap == null || that.wordMap == null) return; that.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String word, int count) { TweetCountWordMap.this.wordMap.adjustOrPutValue(word, count, count); return true; } }); } /**
/** * Add values from "that" to those in this if they exist, otherwise create the element * and start a new count * @param that */ public void combine(TweetCountWordMap that) { this.ntweets += that.ntweets; if(this.wordMap == null || that.wordMap == null) return; that.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String word, int count) { TweetCountWordMap.this.wordMap.adjustOrPutValue(word, count, count); return true; } }); } /**
@Override public void writeEnd() throws IOException { // Output results. File outFile = new File("tagcount.csv"); PrintStream os = new PrintStream(outFile); stringWeights.forEachEntry((s, n) -> { if (n > 100000) { os.printf("%d|%s\n", n, s); } return true; // continue iteration }); os.close(); }
/** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectIntProcedure<K>() { private boolean first = true; public boolean execute( K key, int value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectIntHashMap
/** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectIntProcedure<K>() { private boolean first = true; public boolean execute( K key, int value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectIntHashMap
public ArrayList<TupleVO> getTuples(final int support) throws Exception { final ArrayList<TupleVO> ret = new ArrayList<TupleVO>(); // Set<ItemVO<Integer, Integer>> mainKeys = map.keySet(); Set<Entry<ItemVO<Integer, Integer>, TObjectIntHashMap<ItemVO<Integer, Integer>>>> entries = map.entrySet(); for (final Entry<ItemVO<Integer, Integer>, TObjectIntHashMap<ItemVO<Integer, Integer>>> entry : entries) { entry.getValue().forEachEntry(new TObjectIntProcedure<ItemVO<Integer, Integer>>() { public boolean execute(ItemVO<Integer, Integer> a, int b) { if (b >= support) { ret.add(new TupleVO(entry.getKey() , a, b)); } return true; } }); } return ret; }
/** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectIntProcedure<K>() { private boolean first = true; public boolean execute( K key, int value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectIntHashMap
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectIntProcedure<K>() { private boolean first = true; @Override public boolean execute( K key, int value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectIntHashMap
@Override public ShareableResource copy() { ShareableResource rc = new ShareableResource(rcId, nodesCapacity.getNoEntryValue(), vmsConsumption.getNoEntryValue()); vmsConsumption.forEachEntry((vm, c) -> { rc.vmsConsumption.put(vm, c); return true; }); nodesCapacity.forEachEntry((n, c) -> { rc.nodesCapacity.put(n, c); return true; }); return rc; }
@Override public void writeBinary(final DataOutput out) throws IOException { new WriteableStringIntPair("ntweets",this.ntweets).writeBinary(out); out.writeInt(this.wordMap.size()); this.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String word, int count) { try { new WriteableStringIntPair(word,count).writeBinary(out); } catch (IOException e) {} return true; } }); }
@Override public void writeBinary(final DataOutput out) throws IOException { new WriteableStringIntPair("ntweets",this.ntweets).writeBinary(out); out.writeInt(this.wordMap.size()); this.wordMap.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String word, int count) { try { new WriteableStringIntPair(word,count).writeBinary(out); } catch (IOException e) {} return true; } }); }
/** * Factor decomposition with specified factors and exponents * * @param factors factors */ public static <Poly extends IPolynomial<Poly>> PolynomialFactorDecomposition<Poly> of(Collection<Poly> factors) { TObjectIntHashMap<Poly> map = new TObjectIntHashMap<>(); for (Poly e : factors) map.adjustOrPutValue(e, 1, 1); List<Poly> l = new ArrayList<>(); TIntArrayList e = new TIntArrayList(); map.forEachEntry((a, b) -> { l.add(a); e.add(b); return true; }); return of(factors.iterator().next().createOne(), l, e); } }
@Override public boolean findMatches(List<T> queryfeatures) { matches = new ArrayList<Pair<T>>(); final TObjectIntHashMap<T> targets = new TObjectIntHashMap<T>(); for (final T query : queryfeatures) { final T modeltarget = findMatch(query, modelKeypoints); if (modeltarget == null) continue; final T querytarget = findMatch(modeltarget, queryfeatures); if (querytarget == query) { matches.add(new Pair<T>(query, modeltarget)); targets.adjustOrPutValue(modeltarget, 1, 1); } } final ArrayList<Pair<T>> matchesToRemove = new ArrayList<Pair<T>>(); targets.forEachEntry(new TObjectIntProcedure<T>() { @Override public boolean execute(T a, int b) { if (b > 1) { for (final Pair<T> p : matches) { if (p.secondObject() == a) matchesToRemove.add(p); } } return true; } }); matches.removeAll(matchesToRemove); return matches.size() > 0; }
/** * Factor decomposition with specified factors and exponents * * @param ring the ring * @param factors factors */ public static <E> FactorDecomposition<E> of(Ring<E> ring, Collection<E> factors) { TObjectIntHashMap<E> map = new TObjectIntHashMap<>(); for (E e : factors) map.adjustOrPutValue(e, 1, 1); List<E> l = new ArrayList<>(); TIntArrayList e = new TIntArrayList(); map.forEachEntry((a, b) -> { l.add(a); e.add(b); return true; }); return of(ring, ring.getOne(), l, e); } }