• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TObjectDoubleProcedure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.trove.TObjectDoubleProcedure的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleProcedure类的具体用法?Java TObjectDoubleProcedure怎么用?Java TObjectDoubleProcedure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TObjectDoubleProcedure类属于gnu.trove包,在下文中一共展示了TObjectDoubleProcedure类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: argmax

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
/** Returns the key in map that has the greatest score */
public static Object argmax (TObjectDoubleHashMap map)
{
  // A local class! Yes, Virginia, this is legal Java.
  class Accumulator implements TObjectDoubleProcedure {
    double bestVal = Double.NEGATIVE_INFINITY;
    Object bestObj = null;
    public boolean execute (Object a, double b)
    {
      if (b > bestVal) {
        bestVal = b;
        bestObj = a;
      }
      return true;
    }
  }

  Accumulator procedure = new Accumulator ();
  map.forEachEntry (procedure);
  return procedure.bestObj;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:22,代码来源:CollectionUtils.java


示例2: updateTotalProgress

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
private double updateTotalProgress(Operation currentOperation) {
  // marking all operations before this one as completed
  for (Operation op : Operation.values()) {
    if (currentOperation.compareTo(op) > 0) {
      myOperationsProgress.put(op, 1.0);
    }
  }
  // counting progress
  final double[] totalProgress = new double[1];
  myOperationsProgress.forEachEntry(new TObjectDoubleProcedure<Operation>() {
    @Override
    public boolean execute(Operation operation, double progress) {
      totalProgress[0] += operation.myFractionInTotal * progress;
      return true;
    }
  });
  return totalProgress[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GitStandardProgressAnalyzer.java


示例3: add

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
public Counter<T> add(final double val) {
	final Counter<T> result = new Counter<T>();
	m_map.forEachEntry(new TObjectDoubleProcedure<T>() {
           private boolean first = true;
           public boolean execute(T key, double value) {
           	if ( first ) first = false;
           	double newValue = value + val;
            result.set(key, newValue);
               return true;
           }
       });
	return result;
}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:14,代码来源:Counter.java


示例4: divideAllBy

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
/**
 * For each entry in this counter, looks up the corresponding entry in {@code that} 
 * and stores their ratio in the result.
 * @param that
 */
public Counter<T> divideAllBy(final Counter<? super T> that) {
	final Counter<T> result = new Counter<T>();
	m_map.forEachEntry(new TObjectDoubleProcedure<T>() {
           private boolean first = true;
           public boolean execute(T key, double value) {
           	if ( first ) first = false;
           	double newValue = value / that.getT(key);
            result.set(key, newValue);
               return true;
           }
       });
	return result;
}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:19,代码来源:Counter.java


示例5: scaleAllBy

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
/**
 * For each entry in this counter, looks up the corresponding entry in {@code that} 
 * and stores their product in the result.
 * @param that
 */
public Counter<T> scaleAllBy(final Counter<? super T> that) {
	final Counter<T> result = new Counter<T>();
	m_map.forEachEntry(new TObjectDoubleProcedure<T>() {
           private boolean first = true;
           public boolean execute(T key, double value) {
           	if ( first ) first = false;
           	double newValue = value * that.getT(key);
            result.set(key, newValue);
               return true;
           }
       });
	return result;
}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:19,代码来源:Counter.java


示例6: toString

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
/**
 * @param valueThreshold
 * @param sep Array with two Strings: an entry separator ("," by default, if this is {@code null}), and a key-value separator ("=" by default)
 * @return A string representation of all (key, value) pairs such that the value equals or exceeds the given threshold
 */
public String toString(final double valueThreshold, String[] sep) {
   	String entrySep = ",";	// default
	String kvSep = "=";	// default
	if (sep!=null && sep.length>0) {
		if (sep[0]!=null) 
			entrySep = sep[0];
		if (sep.length>1 && sep[1]!=null)
			kvSep = sep[1];
	}
	final String ENTRYSEP = entrySep;
	final String KVSEP = kvSep;
       final StringBuilder buf = new StringBuilder("{");
       m_map.forEachEntry(new TObjectDoubleProcedure<T>() {
           private boolean first = true;
           public boolean execute(T key, double value) {
           	if (value >= valueThreshold) {
                if ( first ) first = false;
                else buf.append(ENTRYSEP);

                buf.append(key);
                buf.append(KVSEP);
                buf.append(value);
           	}
               return true;
           }
       });
       buf.append("}");
       return buf.toString();
}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:35,代码来源:Counter.java


示例7: sumOfProducts

import gnu.trove.TObjectDoubleProcedure; //导入依赖的package包/类
/**
 * Computes the sum of products of key-value pairs in {@code that}
 * @param that
 * @return
 */
public static double sumOfProducts(Counter<Integer> that) {
	final double[] result = new double[1];	// use a single-element array to make this variable 'final'
	result[0] = 0;
	that.m_map.forEachEntry(new TObjectDoubleProcedure<Integer>() {
           private boolean first = true;
           public boolean execute(Integer key, double value) {
           	if ( first ) first = false;
           	result[0] += key * value;
               return true;
           }
       });
	return result[0];
}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:19,代码来源:Counter.java



注:本文中的gnu.trove.TObjectDoubleProcedure类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Function类代码示例发布时间:2022-05-22
下一篇:
Java GetQueueInfoResponseProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap