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


Java Int2DoubleOpenHashMap.addTo方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap.addTo方法的典型用法代码示例。如果您正苦于以下问题:Java Int2DoubleOpenHashMap.addTo方法的具体用法?Java Int2DoubleOpenHashMap.addTo怎么用?Java Int2DoubleOpenHashMap.addTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap的用法示例。


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

示例1: testWriteTo

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
@Test
public void testWriteTo() throws Exception {
  ByteBuf buf = Unpooled.buffer(16);
  buf.writeDouble(0.00);
  buf.writeDouble(1.00);
  buf.writeDouble(2.00);
  serverSparseDoubleRow.update(RowType.T_DOUBLE_DENSE, buf, 3);
  DataOutputStream out = new DataOutputStream(new FileOutputStream("data"));
  serverSparseDoubleRow.writeTo(out);
  out.close();
  DataInputStream in = new DataInputStream(new FileInputStream("data"));
  assertEquals(in.readInt(), 3);
  Int2DoubleOpenHashMap hashMap = new Int2DoubleOpenHashMap();
  hashMap.addTo(0, 0.00);
  hashMap.addTo(1, 1.00);
  hashMap.addTo(2, 2.00);
  assertEquals(serverSparseDoubleRow.getData(), hashMap);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ServerSparseDoubleRowTest.java

示例2: testUpdateDoubleSparseToDoubleSparse

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
@Test
public void testUpdateDoubleSparseToDoubleSparse() throws Exception {
  ServerSparseDoubleRow serverSparseDoubleRow =
      new ServerSparseDoubleRow(rowId, startCol, endCol);
  ByteBuf buf = Unpooled.buffer(16);
  buf.writeInt(0);
  buf.writeDouble(0.00);
  buf.writeInt(1);
  buf.writeDouble(1.00);
  buf.writeInt(2);
  buf.writeDouble(2.00);
  rowUpdater.updateDoubleSparseToDoubleSparse(3, buf, serverSparseDoubleRow);
  Int2DoubleOpenHashMap hashMap = new Int2DoubleOpenHashMap();
  hashMap.addTo(0, 0.00);
  hashMap.addTo(1, 1.00);
  hashMap.addTo(2, 2.00);
  assertEquals(serverSparseDoubleRow.getData(), hashMap);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:DefaultRowUpdaterTest.java

示例3: getProductMap

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
private Int2DoubleMap getProductMap(int uidx) {
    Int2DoubleOpenHashMap productMap = new Int2DoubleOpenHashMap();
    productMap.defaultReturnValue(0.0);

    if (data.useIteratorsPreferentially()) {
        IntIterator iidxs = data.getUidxIidxs(uidx);
        DoubleIterator ivs = data.getUidxVs(uidx);
        while (iidxs.hasNext()) {
            int iidx = iidxs.nextInt();
            double iv = ivs.nextDouble();
            IntIterator vidxs = data.getIidxUidxs(iidx);
            DoubleIterator vvs = data.getIidxVs(iidx);
            while (vidxs.hasNext()) {
                productMap.addTo(vidxs.nextInt(), iv * vvs.nextDouble());
            }
        }
    } else {
        data.getUidxPreferences(uidx)
                .forEach(ip -> data.getIidxPreferences(ip.v1)
                        .forEach(up -> productMap.addTo(up.v1, ip.v2 * up.v2)));
    }

    productMap.remove(uidx);

    return productMap;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:27,代码来源:VectorSimilarity.java

示例4: testUpdateDoubleDenseToDoubleSparse

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
@Test
public void testUpdateDoubleDenseToDoubleSparse() throws Exception {
  ServerSparseDoubleRow serverSparseDoubleRow =
      new ServerSparseDoubleRow(rowId, startCol, endCol);
  ByteBuf buf = Unpooled.buffer(16);
  buf.writeDouble(0.00);
  buf.writeDouble(1.00);
  buf.writeDouble(2.00);
  rowUpdater.updateDoubleDenseToDoubleSparse(3, buf, serverSparseDoubleRow);
  Int2DoubleOpenHashMap hashMap = new Int2DoubleOpenHashMap();
  hashMap.addTo(0, 0.00);
  hashMap.addTo(1, 1.00);
  hashMap.addTo(2, 2.00);
  assertEquals(serverSparseDoubleRow.getData(), hashMap);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:16,代码来源:DefaultRowUpdaterTest.java


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