本文整理汇总了Java中gnu.trove.map.hash.TObjectFloatHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectFloatHashMap.put方法的具体用法?Java TObjectFloatHashMap.put怎么用?Java TObjectFloatHashMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.hash.TObjectFloatHashMap
的用法示例。
在下文中一共展示了TObjectFloatHashMap.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queueAmbientSounds
import gnu.trove.map.hash.TObjectFloatHashMap; //导入方法依赖的package包/类
public void queueAmbientSounds(@Nonnull final TObjectFloatHashMap<SoundEffect> sounds) {
// Iterate through the existing emitters:
// * If done, remove
// * If not in the incoming list, fade
// * If it does exist, update volume throttle and unfade if needed
final Iterator<Entry<SoundEffect, Emitter>> itr = this.emitters.entrySet().iterator();
while (itr.hasNext()) {
final Entry<SoundEffect, Emitter> e = itr.next();
final Emitter emitter = e.getValue();
if (emitter.isDonePlaying()) {
DSurround.log().debug("Removing emitter: %s", emitter.toString());
itr.remove();
} else if (sounds.contains(e.getKey())) {
emitter.setVolumeThrottle(sounds.get(e.getKey()));
if (emitter.isFading())
emitter.unfade();
// Set to 0 so that the "new sound" logic below
// will ignore. Cheaper than removing the object
// from the collection.
sounds.put(e.getKey(), 0F);
} else {
if (!emitter.isFading())
emitter.fade();
}
}
// Any sounds left in the list are new and need
// an emitter created.
final TObjectFloatIterator<SoundEffect> newSounds = sounds.iterator();
while (newSounds.hasNext()) {
newSounds.advance();
if (newSounds.value() > 0) {
final SoundEffect effect = newSounds.key();
this.emitters.put(effect, new PlayerEmitter(effect));
}
}
}
示例2: getSimilar
import gnu.trove.map.hash.TObjectFloatHashMap; //导入方法依赖的package包/类
@Override
public List<ScoreElement> getSimilar(SegmentContainer sc, ReadableQueryConfig qc) {
TObjectFloatHashMap<String> tagScores = new TObjectFloatHashMap<>();
for(Tag tag : sc.getTags()){
if(!tag.hasId() && !tag.hasName()){
LOGGER.info("skipping empty tag");
continue;
}
if(!tag.hasId()){
List<Tag> tags = tagHandler.getTagsByName(tag.getName());
for(Tag t : tags){
tagScores.put(t.getId(), 1f);
}
}else{
tagScores.put(tag.getId(), 1f);
}
}
return processTagScores(tagScores);
}
示例3: segmentGraph
import gnu.trove.map.hash.TObjectFloatHashMap; //导入方法依赖的package包/类
protected DisjointSetForest<Pixel> segmentGraph(int numVertices, List<SimpleWeightedEdge<Pixel>> edges) {
// sort edges by weight
Collections.sort(edges, SimpleWeightedEdge.ASCENDING_COMPARATOR);
// make a disjoint-set forest
DisjointSetForest<Pixel> u = new DisjointSetForest<Pixel>(numVertices);
for (SimpleWeightedEdge<Pixel> edge : edges) {
u.add(edge.from);
u.add(edge.to);
}
// init thresholds
TObjectFloatHashMap<Pixel> threshold = new TObjectFloatHashMap<Pixel>();
for (Pixel p : u) {
threshold.put(p, k);
}
// for each edge, in non-decreasing weight order...
for (int i = 0; i < edges.size(); i++) {
SimpleWeightedEdge<Pixel> pedge = edges.get(i);
// components connected by this edge
Pixel a = u.find(pedge.from);
Pixel b = u.find(pedge.to);
if (a != b) {
if ((pedge.weight <= threshold.get(a)) && (pedge.weight <= threshold.get(b))) {
a = u.union(a, b);
threshold.put(a, pedge.weight + (k / u.size(a)));
}
}
}
return u;
}
示例4: loadTStringFloatMap
import gnu.trove.map.hash.TObjectFloatHashMap; //导入方法依赖的package包/类
public static TObjectFloatHashMap<String> loadTStringFloatMap(String path) throws IOException {
TObjectFloatHashMap<String> dict = new TObjectFloatHashMap<String>();
BufferedReader bfr = new BufferedReader(new InputStreamReader(new FileInputStream(path), "utf8"));
String line = null;
while ((line = bfr.readLine()) != null) {
if (line.length() == 0)
continue;
int idx = line.lastIndexOf("\t");
dict.put(line.substring(0, idx), Float.parseFloat(line.substring(idx + 1)));
}
bfr.close();
return dict;
}