当前位置: 首页>>代码示例>>Java>>正文


Java TIntDoubleIterator类代码示例

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


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

示例1: toBytes

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
@Override
public void toBytes(final ByteBuf buf)
{
    buf.writeDouble(meanTickTime);
    buf.writeInt(tMap.size());
    TIntDoubleIterator i = tMap.iterator();
    while (i.hasNext())
    {
        i.advance();
        buf.writeInt(i.key());
        buf.writeDouble(i.value());
    }
    buf.writeInt(free);
    buf.writeInt(total);
    buf.writeInt(max);
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:17,代码来源:Data.java

示例2: CreateDualConstraintForSequence

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
private void CreateDualConstraintForSequence(int sequenceId) throws IloException{
    IloLinearNumExpr lhs = cplex.linearNumExpr();
    for (int i = 0; i < sequenceFormDualMatrix[sequenceId].size(); i++) {
        int informationSetId = sequenceFormDualMatrix[sequenceId].get(i);// + (1-game.getSmallestInformationSetId(playerNotToSolveFor)); // map information set ID to 1 indexing. Assumes that information sets are named by consecutive integers
        int valueMultiplier = i == 0? 1 : -1;
        lhs.addTerm(valueMultiplier, dualVars[informationSetId]);
    }

    //IloLinearNumExpr rhs = cplex.linearNumExpr();
    TIntDoubleIterator it = dualPayoffMatrix[sequenceId].iterator();
    for ( int i = dualPayoffMatrix[sequenceId].size(); i-- > 0; ) {
        it.advance();
        lhs.addTerm(-it.value(), strategyVarsBySequenceId[it.key()]);
    }


    dualConstraints.put(sequenceId, cplex.addGe(lhs, 0, "Dual"+sequenceId));
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:19,代码来源:SequenceFormLPSolver.java

示例3: compress

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
public CompressedRowMatrix compress() {
	CompressedRowMatrix c = new CompressedRowMatrix(rows, cols);
	int entryCount = getNumberOfEntries();
	c.columnIndices = new int[entryCount];
	c.values = new double[entryCount];
	int idx = 0;
	for (int row = 0; row < rows; row++) {
		c.rowPointers[row] = idx;
		TIntDoubleHashMap rowMap = data.get(row);
		if (rowMap == null)
			continue;
		TIntDoubleIterator it = rowMap.iterator();
		while (it.hasNext()) {
			it.advance();
			c.columnIndices[idx] = it.key();
			c.values[idx] = it.value();
			idx++;
		}
	}
	return c;
}
 
开发者ID:GreenDelta,项目名称:olca-modules,代码行数:22,代码来源:HashMatrix.java

示例4: toBytes

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
@Override
public void toBytes(@Nonnull final ByteBuf buf) {
	buf.writeDouble(this.meanTickTime);
	buf.writeInt(this.tMap.size());
	TIntDoubleIterator i = this.tMap.iterator();
	while (i.hasNext()) {
		i.advance();
		buf.writeInt(i.key());
		buf.writeDouble(i.value());
	}
	buf.writeInt(this.free);
	buf.writeInt(this.total);
	buf.writeInt(this.max);
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:15,代码来源:PacketServerData.java

示例5: sortByValue

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
public static Map sortByValue(TIntDoubleHashMap unsortMap) {
    if (unsortMap.isEmpty()) {
        return new HashMap();
    }
    HashMap<Integer, Double> tempMap = new HashMap<Integer, Double>();
    TIntDoubleIterator iterator = unsortMap.iterator();
    for ( int i = unsortMap.size(); i-- > 0; ) {
        iterator.advance();
        tempMap.put( iterator.key(), iterator.value() );
    }
    List<Map.Entry> list = new LinkedList<Map.Entry>(tempMap.entrySet());

    // sort list based on comparator
    Collections.sort(list, Collections.reverseOrder(new Comparator() {
        public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getValue())
                    .compareTo(((Map.Entry) (o2)).getValue());
        }
    }));

    Map sortedMap = new LinkedHashMap();
    for (Iterator it = list.iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        sortedMap.put(entry.getKey(), entry.getValue());
    }
    return sortedMap;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:28,代码来源:SimUtils.java

示例6: sortMapByValue

import gnu.trove.iterator.TIntDoubleIterator; //导入依赖的package包/类
/**
 * Sort a given {@link TIntDoubleMap} by its values
 * 
 * @param map
 *            in map
 * @param descending
 *            determine the order of the sort: true - descending, false -
 *            ascending
 * @return out sorted-by-values map
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static LinkedHashMap<Integer,Double> sortMapByValue(TIntDoubleMap map, final boolean descending) {
	List<Pair<Integer,Double>> list = new LinkedList<Pair<Integer,Double>>();
	TIntDoubleIterator it1 = map.iterator();
	while (it1.hasNext()) {
		it1.advance();
		list.add(new Pair<Integer, Double>(it1.key(),it1.value()));
	}
	Collections.sort(list, new Comparator() {
	@Override
	public int compare(Object o1, Object o2) {
			int ret = ((Comparable) ((Pair) (o1)).getSecond())
					.compareTo(((Pair) (o2)).getSecond());
			if (descending)
				ret *= -1;
			return ret;
		}
	});

	LinkedHashMap<Integer,Double> result = new LinkedHashMap<Integer,Double>();
	Iterator<Pair<Integer,Double>> it2 = list.iterator();
	while (it2.hasNext()) {
		Pair<Integer,Double> pair = it2.next();
		result.put(pair.getFirst(), pair.getSecond());
	}
	return result;
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:38,代码来源:SortUtil.java


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