本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2ObjectMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java Long2ObjectMap.put方法的具体用法?Java Long2ObjectMap.put怎么用?Java Long2ObjectMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.longs.Long2ObjectMap
的用法示例。
在下文中一共展示了Long2ObjectMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleNodeVisitor
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
@Test
public void testSimpleNodeVisitor() throws Exception {
SalsaNodeVisitor.SimpleNodeVisitor simpleNodeVisitor =
new SalsaNodeVisitor.SimpleNodeVisitor(
salsaInternalState.getVisitedRightNodes());
simpleNodeVisitor.resetWithRequest(salsaRequest);
simpleNodeVisitor.visitRightNode(1, 2, (byte) 0, 0L, 1);
simpleNodeVisitor.visitRightNode(2, 3, (byte) 0, 0L, 1);
simpleNodeVisitor.visitRightNode(1, 3, (byte) 0, 0L, 1);
Long2ObjectMap<NodeInfo> expectedVisitedRightNodesMap =
new Long2ObjectOpenHashMap<NodeInfo>(2);
expectedVisitedRightNodesMap.put(2, new NodeInfo(2, 1, 1));
expectedVisitedRightNodesMap.put(3, new NodeInfo(3, 2, 1));
assertEquals(expectedVisitedRightNodesMap, salsaInternalState.getVisitedRightNodes());
}
示例2: testNodeVisitorWithSocialProof
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
@Test
public void testNodeVisitorWithSocialProof() throws Exception {
SalsaNodeVisitor.NodeVisitorWithSocialProof nodeVisitorWithSocialProof =
new SalsaNodeVisitor.NodeVisitorWithSocialProof(
salsaInternalState.getVisitedRightNodes());
nodeVisitorWithSocialProof.resetWithRequest(salsaRequest);
nodeVisitorWithSocialProof.visitRightNode(1, 2, (byte) 0, 0L, 1);
nodeVisitorWithSocialProof.visitRightNode(2, 3, (byte) 0, 0L, 1);
nodeVisitorWithSocialProof.visitRightNode(1, 3, (byte) 0, 0L, 1);
NodeInfo node2 = new NodeInfo(2, 1, 1);
NodeInfo node3 = new NodeInfo(3, 2, 1);
assertTrue(node3.addToSocialProof(2, (byte) 0, 0L, 1));
Long2ObjectMap<NodeInfo> expectedVisitedRightNodesMap =
new Long2ObjectOpenHashMap<NodeInfo>(2);
expectedVisitedRightNodesMap.put(2, node2);
expectedVisitedRightNodesMap.put(3, node3);
assertEquals(expectedVisitedRightNodesMap, salsaInternalState.getVisitedRightNodes());
}
示例3: buildTestGraph
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
private StaticBipartiteGraph buildTestGraph() {
Long2ObjectMap<LongList> leftSideGraph = new Long2ObjectOpenHashMap<LongList>(3);
leftSideGraph.put(1, new LongArrayList(new long[]{2, 3, 4, 5}));
leftSideGraph.put(2, new LongArrayList(new long[]{tweetNode, summaryNode, photoNode, playerNode,
2, 3}));
leftSideGraph.put(3, new LongArrayList(new long[]{tweetNode, summaryNode, photoNode, playerNode,
promotionNode, 4, 5}));
Long2ObjectMap<LongList> rightSideGraph = new Long2ObjectOpenHashMap<LongList>(10);
rightSideGraph.put(2, new LongArrayList(new long[]{1, 2}));
rightSideGraph.put(3, new LongArrayList(new long[]{1, 2}));
rightSideGraph.put(4, new LongArrayList(new long[]{1, 3}));
rightSideGraph.put(5, new LongArrayList(new long[]{1, 3}));
rightSideGraph.put(tweetNode, new LongArrayList(new long[]{2, 3}));
rightSideGraph.put(summaryNode, new LongArrayList(new long[]{2, 3}));
rightSideGraph.put(photoNode, new LongArrayList(new long[]{2, 3}));
rightSideGraph.put(playerNode, new LongArrayList(new long[]{2, 3}));
rightSideGraph.put(promotionNode, new LongArrayList(new long[]{3}));
return new StaticBipartiteGraph(leftSideGraph, rightSideGraph);
}
示例4: buildRandomBipartiteGraph
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
/**
* Build a random bipartite graph of given left and right sizes.
*
* @param leftSize is the left hand size of the bipartite graph
* @param rightSize is the right hand size of the bipartite graph
* @param random is the random number generator to use for constructing the graph
* @return a random bipartite graph
*/
public static StaticBipartiteGraph buildRandomBipartiteGraph(
int leftSize, int rightSize, double edgeProbability, Random random) {
Long2ObjectMap<LongList> leftSideGraph = new Long2ObjectOpenHashMap<LongList>(leftSize);
Long2ObjectMap<LongList> rightSideGraph = new Long2ObjectOpenHashMap<LongList>(rightSize);
int averageLeftDegree = (int) (rightSize * edgeProbability);
int averageRightDegree = (int) (leftSize * edgeProbability);
for (int i = 0; i < leftSize; i++) {
leftSideGraph.put(i, new LongArrayList(averageLeftDegree));
for (int j = 0; j < rightSize; j++) {
if (random.nextDouble() < edgeProbability) {
leftSideGraph.get(i).add(j);
if (rightSideGraph.containsKey(j)) {
rightSideGraph.get(j).add(i);
} else {
LongList rightSideList = new LongArrayList(averageRightDegree);
rightSideList.add(i);
rightSideGraph.put(j, rightSideList);
}
}
}
}
return new StaticBipartiteGraph(leftSideGraph, rightSideGraph);
}
示例5: buildSmallTestBipartiteGraph
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
/**
* Build a small test bipartite graph.
*
* @return a small test bipartite graph
*/
public static StaticBipartiteGraph buildSmallTestBipartiteGraph() {
Long2ObjectMap<LongList> leftSideGraph = new Long2ObjectOpenHashMap<LongList>(3);
leftSideGraph.put(1, new LongArrayList(new long[]{2, 3, 4, 5}));
leftSideGraph.put(2, new LongArrayList(new long[]{5, 6, 10}));
leftSideGraph.put(3, new LongArrayList(new long[]{7, 8, 5, 9, 2, 10, 11, 1}));
Long2ObjectMap<LongList> rightSideGraph = new Long2ObjectOpenHashMap<LongList>(10);
rightSideGraph.put(1, new LongArrayList(new long[]{3}));
rightSideGraph.put(2, new LongArrayList(new long[]{1, 3}));
rightSideGraph.put(3, new LongArrayList(new long[]{1}));
rightSideGraph.put(4, new LongArrayList(new long[]{1}));
rightSideGraph.put(5, new LongArrayList(new long[]{1, 2, 3}));
rightSideGraph.put(6, new LongArrayList(new long[]{2}));
rightSideGraph.put(7, new LongArrayList(new long[]{3}));
rightSideGraph.put(8, new LongArrayList(new long[]{3}));
rightSideGraph.put(9, new LongArrayList(new long[]{3}));
rightSideGraph.put(10, new LongArrayList(new long[]{2, 3}));
rightSideGraph.put(11, new LongArrayList(new long[]{3}));
return new StaticBipartiteGraph(leftSideGraph, rightSideGraph);
}
示例6: canonicalizeAndAddConst
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
private void canonicalizeAndAddConst(
ConstType type, int dest, long value, Long2ObjectMap<ConstNumber> table) {
ConstNumber existing = table.get(value);
if (existing != null) {
currentBlock.writeCurrentDefinition(dest, existing.outValue(), ThrowingInfo.NO_THROW);
} else {
Value out = writeRegister(dest, MoveType.fromConstType(type), ThrowingInfo.NO_THROW);
ConstNumber instruction = new ConstNumber(type, out, value);
BasicBlock entryBlock = blocks.get(0);
if (currentBlock != entryBlock) {
// Insert the constant instruction at the start of the block right after the argument
// instructions. It is important that the const instruction is put before any instruction
// that can throw exceptions (since the value could be used on the exceptional edge).
InstructionListIterator it = entryBlock.listIterator();
while (it.hasNext()) {
if (!it.next().isArgument()) {
it.previous();
break;
}
}
it.add(instruction);
} else {
add(instruction);
}
table.put(value, instruction);
}
}
示例7: testSingleLeftIteration
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
@Test
public void testSingleLeftIteration() throws Exception {
SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
salsaInternalState,
new LeftSalsaIteration(salsaInternalState),
new RightSalsaIteration(salsaInternalState),
new FinalSalsaIteration(salsaInternalState)
);
salsaIterations.resetWithRequest(salsaRequest, random);
SingleSalsaIteration leftSalsaIteration =
new LeftSalsaIteration(salsaInternalState);
leftSalsaIteration.resetWithRequest(salsaRequest, random);
salsaIterations.seedLeftSideForFirstIteration();
leftSalsaIteration.runSingleIteration();
Long2ObjectMap<NodeInfo> expectedVisitedRightNodesMap =
new Long2ObjectOpenHashMap<NodeInfo>(9);
// highest weight
expectedVisitedRightNodesMap.put(2, new NodeInfo(2, 167, 1));
expectedVisitedRightNodesMap.put(3, new NodeInfo(3, 168, 1));
expectedVisitedRightNodesMap.put(4, new NodeInfo(4, 167, 1));
expectedVisitedRightNodesMap.put(5, new NodeInfo(5, 177, 1));
// medium weight
expectedVisitedRightNodesMap.put(6, new NodeInfo(6, 22, 1));
expectedVisitedRightNodesMap.put(10, new NodeInfo(10, 25, 1));
// small weight
expectedVisitedRightNodesMap.put(7, new NodeInfo(7, 2, 1));
expectedVisitedRightNodesMap.put(9, new NodeInfo(9, 1, 1));
expectedVisitedRightNodesMap.put(11, new NodeInfo(11, 1, 1));
assertEquals(1, salsaInternalState.getCurrentLeftNodes().size());
assertEquals(expectedVisitedRightNodesMap, salsaInternalState.getVisitedRightNodes());
}
示例8: buildSmallTestLeftIndexedBipartiteGraph
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
/**
* Build a small test bipartite graph.
*
* @return a small test bipartite graph
*/
public static StaticLeftIndexedBipartiteGraph buildSmallTestLeftIndexedBipartiteGraph() {
Long2ObjectMap<LongList> leftSideGraph = new Long2ObjectOpenHashMap<LongList>(3);
leftSideGraph.put(1, new LongArrayList(new long[]{2, 3, 4, 5}));
leftSideGraph.put(2, new LongArrayList(new long[]{5, 6, 10}));
leftSideGraph.put(3, new LongArrayList(new long[]{7, 8, 5, 9, 2, 10, 11, 1}));
return new StaticLeftIndexedBipartiteGraph(leftSideGraph);
}
示例9: getValueSpecifications
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
public static Long2ObjectMap<ValueSpecification> getValueSpecifications(final IdentifierMap map, final LongCollection identifiers) {
final Long2ObjectMap<ValueSpecification> specifications = new Long2ObjectOpenHashMap<ValueSpecification>();
for (Long identifier : identifiers) {
specifications.put(identifier, map.getValueSpecification(identifier));
}
return specifications;
}
示例10: getValueSpecifications
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
@Override
public Long2ObjectMap<ValueSpecification> getValueSpecifications(LongCollection identifiers) {
final SpecificationLookupRequest request = new SpecificationLookupRequest(identifiers);
final SpecificationLookupResponse response = getRemoteCacheClient().sendGetMessage(request, SpecificationLookupResponse.class);
final List<ValueSpecification> specifications = response.getSpecification();
final Long2ObjectMap<ValueSpecification> specificationMap = new Long2ObjectOpenHashMap<ValueSpecification>();
int i = 0;
for (Long identifier : request.getIdentifier()) {
specificationMap.put(identifier, MemoryUtils.instance(specifications.get(i++)));
}
return specificationMap;
}
示例11: getValueSpecifications
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
public Long2ObjectMap<ValueSpecification> getValueSpecifications(final long[] identifiers) {
final Long2ObjectMap<ValueSpecification> result = new Long2ObjectOpenHashMap<ValueSpecification>();
for (long identifier : identifiers) {
result.put(identifier, getValueSpecification(identifier));
}
return result;
}
示例12: testFinalLeftIteration
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
@Test
public void testFinalLeftIteration() throws Exception {
SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
salsaInternalState,
new LeftSalsaIteration(salsaInternalState),
new RightSalsaIteration(salsaInternalState),
new FinalSalsaIteration(salsaInternalState)
);
salsaIterations.resetWithRequest(salsaRequest, random);
SingleSalsaIteration leftSalsaIteration =
new FinalSalsaIteration(salsaInternalState);
leftSalsaIteration.resetWithRequest(salsaRequest, random);
salsaIterations.seedLeftSideForFirstIteration();
leftSalsaIteration.runSingleIteration();
Long2ObjectMap<NodeInfo> expectedVisitedRightNodesMap =
new Long2ObjectOpenHashMap<NodeInfo>(9);
NodeInfo node2 = new NodeInfo(2, 167, 1);
node2.addToSocialProof(3, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(2, node2);
NodeInfo node3 = new NodeInfo(3, 168, 1);
expectedVisitedRightNodesMap.put(3, node3);
NodeInfo node4 = new NodeInfo(4, 167, 1);
expectedVisitedRightNodesMap.put(4, node4);
NodeInfo node5 = new NodeInfo(5, 177, 1);
node5.addToSocialProof(3, (byte) 0, 0L, 1.0);
node5.addToSocialProof(2, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(5, node5);
NodeInfo node6 = new NodeInfo(6, 22, 1);
node6.addToSocialProof(2, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(6, node6);
NodeInfo node7 = new NodeInfo(7, 2, 1);
node7.addToSocialProof(3, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(7, node7);
NodeInfo node9 = new NodeInfo(9, 1, 1);
node9.addToSocialProof(3, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(9, node9);
NodeInfo node10 = new NodeInfo(10, 25, 1);
node10.addToSocialProof(3, (byte) 0, 0L, 1.0);
node10.addToSocialProof(2, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(10, node10);
NodeInfo node11 = new NodeInfo(11, 1, 1);
node11.addToSocialProof(3, (byte) 0, 0L, 1.0);
expectedVisitedRightNodesMap.put(11, node11);
assertEquals(expectedVisitedRightNodesMap, salsaInternalState.getVisitedRightNodes());
}
示例13: regenerateChunk
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
IChunkProvider provider = world.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
return false;
}
BlockFalling.fallInstantly = true;
try {
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
long pos = ChunkPos.asLong(x, z);
Chunk mcChunk;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
mcChunk.onChunkUnload();
}
PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
List<EntityPlayerMP> oldWatchers = null;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
if (entry != null) {
Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
fieldPlayers.setAccessible(true);
oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
playerManager.removeEntry(entry);
}
mcChunk.onChunkUnload();
}
try {
Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
droppedChunksSetField.setAccessible(true);
Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
droppedChunksSet.remove(pos);
} catch (Throwable e) {
MainUtil.handleError(e);
}
Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
id2ChunkMap.remove(pos);
mcChunk = gen.provideChunk(x, z);
id2ChunkMap.put(pos, mcChunk);
if (mcChunk != null) {
mcChunk.onChunkLoad();
mcChunk.populateChunk(chunkServer, gen);
}
if (oldWatchers != null) {
for (EntityPlayerMP player : oldWatchers) {
playerManager.addPlayer(player);
}
}
return true;
} catch (Throwable t) {
MainUtil.handleError(t);
return false;
} finally {
BlockFalling.fallInstantly = false;
}
}
示例14: regenerateChunk
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
IChunkProvider provider = world.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
return false;
}
BlockFalling.fallInstantly = true;
try {
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
long pos = ChunkPos.asLong(x, z);
Chunk mcChunk;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
mcChunk.onUnload();
}
PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
List<EntityPlayerMP> oldWatchers = null;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
if (entry != null) {
Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
fieldPlayers.setAccessible(true);
oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
playerManager.removeEntry(entry);
}
mcChunk.onUnload();
}
try {
Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
droppedChunksSetField.setAccessible(true);
Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
droppedChunksSet.remove(pos);
} catch (Throwable e) {
MainUtil.handleError(e);
}
Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
id2ChunkMap.remove(pos);
mcChunk = gen.generateChunk(x, z);
id2ChunkMap.put(pos, mcChunk);
if (mcChunk != null) {
mcChunk.onLoad();
mcChunk.populate(chunkServer, gen);
}
if (oldWatchers != null) {
for (EntityPlayerMP player : oldWatchers) {
playerManager.addPlayer(player);
}
}
return true;
} catch (Throwable t) {
MainUtil.handleError(t);
return false;
} finally {
BlockFalling.fallInstantly = false;
}
}
示例15: regenerateChunk
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入方法依赖的package包/类
public boolean regenerateChunk(World world, int x, int z) {
IChunkProvider provider = world.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
return false;
}
BlockFalling.fallInstantly = true;
try {
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
long pos = ChunkPos.asLong(x, z);
Chunk mcChunk;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
mcChunk.onUnload();
}
PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
List<EntityPlayerMP> oldWatchers = null;
if (chunkServer.chunkExists(x, z)) {
mcChunk = chunkServer.loadChunk(x, z);
PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
if (entry != null) {
Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
fieldPlayers.setAccessible(true);
oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
playerManager.removeEntry(entry);
}
mcChunk.onUnload();
}
try {
Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
droppedChunksSetField.setAccessible(true);
Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
droppedChunksSet.remove(pos);
} catch (Throwable e) {
MainUtil.handleError(e);
}
Long2ObjectMap<Chunk> id2ChunkMap = chunkServer.id2ChunkMap;
id2ChunkMap.remove(pos);
mcChunk = gen.generateChunk(x, z);
id2ChunkMap.put(pos, mcChunk);
if (mcChunk != null) {
mcChunk.onLoad();
mcChunk.populate(chunkServer, gen);
}
if (oldWatchers != null) {
for (EntityPlayerMP player : oldWatchers) {
playerManager.addPlayer(player);
}
}
return true;
} catch (Throwable t) {
MainUtil.handleError(t);
return false;
} finally {
BlockFalling.fallInstantly = false;
}
}