本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2ObjectMap类的典型用法代码示例。如果您正苦于以下问题:Java Long2ObjectMap类的具体用法?Java Long2ObjectMap怎么用?Java Long2ObjectMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Long2ObjectMap类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了Long2ObjectMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCountLoadedChunks
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
public int getCountLoadedChunks()
{
if (this.theWorld == null)
{
return 0;
}
else
{
IChunkProvider ichunkprovider = this.theWorld.getChunkProvider();
if (ichunkprovider == null)
{
return 0;
}
else
{
if (ichunkprovider != this.worldChunkProvider)
{
this.worldChunkProvider = ichunkprovider;
this.worldChunkProviderMap = (Long2ObjectMap)Reflector.getFieldValue(ichunkprovider, Reflector.ChunkProviderClient_chunkMapping);
}
return this.worldChunkProviderMap == null ? 0 : this.worldChunkProviderMap.size();
}
}
}
示例2: updateAlgorithmStats
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
private void updateAlgorithmStats(long queryNode) {
topSecondDegreeByCountStats.setNumDirectNeighbors(
leftIndexedBipartiteGraph.getLeftNodeDegree(queryNode)
);
int minVisitsPerRightNode = Integer.MAX_VALUE;
int maxVisitsPerRightNode = 0;
int numRHSVisits = 0;
for (Long2ObjectMap.Entry<NodeInfo> entry: visitedRightNodes.long2ObjectEntrySet()) {
NodeInfo nodeInfo = entry.getValue();
int numVisits = nodeInfo.getNumVisits();
minVisitsPerRightNode = Math.min(minVisitsPerRightNode, numVisits);
maxVisitsPerRightNode = Math.max(maxVisitsPerRightNode, numVisits);
numRHSVisits += numVisits;
}
topSecondDegreeByCountStats.setMinVisitsPerRightNode(minVisitsPerRightNode);
topSecondDegreeByCountStats.setMaxVisitsPerRightNode(maxVisitsPerRightNode);
topSecondDegreeByCountStats.setNumRHSVisits(numRHSVisits);
topSecondDegreeByCountStats.setNumRightNodesReached(visitedRightNodes.size());
}
示例3: 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());
}
示例4: 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());
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: pairToEntry
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
public static Long2ObjectMap.Entry pairToEntry(final LongObjectPair pair) {
return new Long2ObjectMap.Entry() {
@Override
public long getLongKey() {
return pair.getFirstLong();
}
@Override
public Object getKey() {
return pair.getFirst();
}
@Override
public Object getValue() {
return pair.getSecond();
}
@Override
public Object setValue(Object value) {
throw new UnsupportedOperationException("This entry is immutable");
}
};
}
示例9: convertIdentifiers
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
@Override
public void convertIdentifiers(final Long2ObjectMap<ValueSpecification> identifiers) {
if (_inputSpecifications == null) {
if (_inputIdentifiers.length > 0) {
_inputSpecifications = new ValueSpecification[_inputIdentifiers.length];
for (int i = 0; i < _inputIdentifiers.length; i++) {
_inputSpecifications[i] = identifiers.get(_inputIdentifiers[i]);
}
} else {
_inputSpecifications = EMPTY_VALUESPEC;
}
}
if (_outputSpecifications == null) {
if (_outputIdentifiers.length > 0) {
_outputSpecifications = new ValueSpecification[_outputIdentifiers.length];
for (int i = 0; i < _outputIdentifiers.length; i++) {
_outputSpecifications[i] = identifiers.get(_outputIdentifiers[i]);
}
} else {
_outputSpecifications = EMPTY_VALUESPEC;
}
}
}
示例10: ChunkListener
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
public ChunkListener() {
if (Settings.IMP.TICK_LIMITER.ENABLED) {
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
rateLimit--;
physicsFreeze = false;
itemFreeze = false;
lastZ = Integer.MIN_VALUE;
physSkip = 0;
physCancelPair = Long.MIN_VALUE;
physCancel = false;
counter.clear();
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
long key = entry.getLongKey();
int x = MathMan.unpairIntX(key);
int z = MathMan.unpairIntY(key);
counter.put(key, badLimit);
}
badChunks.clear();
}
}, Settings.IMP.TICK_LIMITER.INTERVAL);
}
}
示例11: onEvent
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
@Override
public void onEvent(TwoPhaseEvent<SparseItem> event) throws Exception {
SparseItem outputItem = event.output();
item.clear();
outputItem.clear();
format.parse(event.input(), item, event.lineNo());
outputItem
.copyCategoricalFeaturesFrom(item)
.label(item.label())
.id(item.id());
Long2ObjectMap<Binning> binnings = statistics.binnings();
for (int i = 0; i < item.numericalIndexes().size(); i++) {
long numericalIndex = item.numericalIndexes().getLong(i);
double numericalValue = item.numericalValues().getDouble(i);
long binningIndex = Util.murmur().newHasher()
.putLong(numericalIndex)
.putDouble(binnings.get(numericalIndex).roundToPercentile(numericalValue))
.hash().asLong();
outputItem.addCategoricalIndex(binningIndex);
}
}
示例12: 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);
}
}
示例13: reset
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
public void reset() {
ObjectIterator<Long2ObjectMap.Entry<ByteBuffer>> it = cache.long2ObjectEntrySet().fastIterator();
while (it.hasNext()) {
it.next().getValue().clear(); // set position less than limit, make hasRemaining() return true so that it reloads
}
inferior.reset();
}
示例14: NodeMetadataSocialProofResult
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
public NodeMetadataSocialProofResult(
int nodeMetadataId,
Byte2ObjectMap<Long2ObjectMap<LongSet>> socialProof,
double weight,
RecommendationType recommendationType
) {
this.nodeMetadataId = nodeMetadataId;
this.socialProof = socialProof;
this.weight = weight;
this.recommendationType = recommendationType;
}
示例15: getSocialProofSize
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; //导入依赖的package包/类
/**
* Calculate the total number of interactions for the current nodeMetadataId (right node's metadata)
* given the set of users (left nodes).
*
* @return the number of unique edgeType/user/tweet interactions.
* For example (0 (byte), 12 (long), 99 (long)) would be a single unique interaction.
*/
public int getSocialProofSize() {
int socialProofSize = 0;
for (Long2ObjectMap<LongSet> userToTweetsMap: socialProof.values()) {
for (LongSet connectingTweets: userToTweetsMap.values()) {
socialProofSize += connectingTweets.size();
}
}
return socialProofSize;
}