本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}