本文整理匯總了Java中it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap類的典型用法代碼示例。如果您正苦於以下問題:Java Long2ObjectOpenHashMap類的具體用法?Java Long2ObjectOpenHashMap怎麽用?Java Long2ObjectOpenHashMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Long2ObjectOpenHashMap類屬於it.unimi.dsi.fastutil.longs包,在下文中一共展示了Long2ObjectOpenHashMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSimpleNodeVisitor
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的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.Long2ObjectOpenHashMap; //導入依賴的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.Long2ObjectOpenHashMap; //導入依賴的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.Long2ObjectOpenHashMap; //導入依賴的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.Long2ObjectOpenHashMap; //導入依賴的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: checkAndStore
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
protected <T> void checkAndStore(long entityId, Class<? super T> type) {
if (isTransaction) {
LongOpenHashSet entityAdded = added.get(type);
if (entityAdded.contains(entityId))
return;
T oldT = repository.get((Class<T>)type, entityId);
Long2ObjectOpenHashMap<Object> data = snapshotted.get(type);
if (oldT == null) {
entityAdded.add(entityId);
} else if (!data.containsKey(entityId)) {
data.put(entityId, oldT);
}
}
}
示例7: loadTagAffinities
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
protected UserTagStore loadTagAffinities(String client,Map<Long,Integer> tagCounts,BufferedReader reader) throws IOException
{
String line;
ObjectMapper mapper = new ObjectMapper();
int numTags = 0;
Map<Long,Map<String,Float>> userTagAffinities = new Long2ObjectOpenHashMap<>(tagCounts.size(),1.0f);
// HashMap<Long,Map<String,Float>>(tagCounts.size(),1.0f);
while((line = reader.readLine()) !=null)
{
UserTagAffinity data = mapper.readValue(line.getBytes(), UserTagAffinity.class);
numTags++;
Map<String,Float> tagMap = userTagAffinities.get(data.user);
if (tagMap == null)
{
tagMap = new Object2FloatOpenHashMap<>(tagCounts.get(data.user),1.0f);
//new HashMap<String,Float>(tagCounts.get(data.user),1.0f);
userTagAffinities.put(data.user, tagMap);
}
tagMap.put(data.tag, data.weight);
}
logger.info("Loaded "+userTagAffinities.keySet().size()+" users with "+numTags+" tags for "+client);
return new UserTagStore(userTagAffinities);
}
示例8: getBlocksForDimension
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
private Long2ObjectOpenHashMap<IDeviceBlock> getBlocksForDimension(int dimensionID)
{
Long2ObjectOpenHashMap<IDeviceBlock> blocks = worldBlocks.get(dimensionID);
if(blocks == null)
{
synchronized(worldBlocks)
{
blocks = worldBlocks.get(dimensionID);
if(blocks == null)
{
blocks = new Long2ObjectOpenHashMap<IDeviceBlock>();
worldBlocks.put(dimensionID, blocks);
}
}
}
return blocks;
}
示例9: initTransitionsMaps
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
/**
* Initializes internal data structures for transitions.
*/
private void initTransitionsMaps() {
if (trId2bpnMap == null) {
trId2bpnMap = new Object2LongOpenHashMap<String>();
trId2bpnMap.defaultReturnValue(-1L);
}
if (tr2InPlacesMap == null) {
tr2InPlacesMap = new Long2ObjectOpenHashMap<>();
tr2InPlacesMap.defaultReturnValue(null);
}
if (tr2OutPlacesMap == null) {
tr2OutPlacesMap = new Long2ObjectOpenHashMap<>();
tr2OutPlacesMap.defaultReturnValue(null);
}
if (tr2InAllArcsMap == null) {
tr2InAllArcsMap = new Object2ObjectOpenHashMap<String, LongBigArrayBigList>();
tr2InAllArcsMap.defaultReturnValue(null);
}
if (tr2OutAllArcsMap == null) {
tr2OutAllArcsMap = new Object2ObjectOpenHashMap<String, LongBigArrayBigList>();
tr2OutAllArcsMap.defaultReturnValue(null);
}
}
示例10: buildConnectedPlaces2Transition
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
/**
* @param bpnsb
* @param trId
*/
private void buildConnectedPlaces2Transition(StringBuilder bpnsb, long trId,
Long2ObjectOpenHashMap<LongBigArrayBigList> tr2PlacesMap) {
LongBigArrayBigList pls;
long plsSize;
pls = tr2PlacesMap.get(trId);
if (pls != null) {
plsSize = pls.size64();
} else { // no place in input or output list of this transition
plsSize = 0L;
}
bpnsb.append(WS).append(HK).append(plsSize);
if (plsSize > 0L) {
for (long plId : pls) {
bpnsb.append(WS).append(plId);
}
}
}
示例11: Instruments
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
private Instruments(List<Instrument> values, int priceIntegerDigits, int maxPriceFractionDigits,
int sizeIntegerDigits, int maxSizeFractionDigits) {
this.valuesByString = new HashMap<>();
this.valuesByLong = new Long2ObjectOpenHashMap<>();
for (Instrument value : values) {
valuesByString.put(value.asString(), value);
valuesByLong.put(value.asLong(), value);
}
this.maxPriceFractionDigits = maxPriceFractionDigits;
this.maxSizeFractionDigits = maxSizeFractionDigits;
this.priceWidth = priceIntegerDigits + (maxPriceFractionDigits > 0 ? 1 : 0) + maxPriceFractionDigits;
this.sizeWidth = sizeIntegerDigits + (maxSizeFractionDigits > 0 ? 1 : 0) + maxSizeFractionDigits;
this.pricePlaceholder = placeholder(priceIntegerDigits, maxPriceFractionDigits);
this.sizePlaceholder = placeholder(sizeIntegerDigits, maxSizeFractionDigits);
}
示例12: LongByteArrayMessageStore
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
/**
* Constructor
*
* @param messageValueFactory Factory for creating message values
* @param service Service worker
* @param config Hadoop configuration
*/
public LongByteArrayMessageStore(
MessageValueFactory<M> messageValueFactory,
CentralizedServiceWorker<LongWritable, ?, ?> service,
ImmutableClassesGiraphConfiguration<LongWritable, ?, ?> config) {
this.messageValueFactory = messageValueFactory;
this.service = service;
this.config = config;
map =
new Int2ObjectOpenHashMap<Long2ObjectOpenHashMap<DataInputOutput>>();
for (int partitionId : service.getPartitionStore().getPartitionIds()) {
Partition<LongWritable, ?, ?> partition =
service.getPartitionStore().getPartition(partitionId);
Long2ObjectOpenHashMap<DataInputOutput> partitionMap =
new Long2ObjectOpenHashMap<DataInputOutput>(
(int) partition.getVertexCount());
map.put(partitionId, partitionMap);
}
}
示例13: readFieldsForPartition
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
@Override
public void readFieldsForPartition(DataInput in,
int partitionId) throws IOException {
int size = in.readInt();
Long2ObjectOpenHashMap<DataInputOutput> partitionMap =
new Long2ObjectOpenHashMap<DataInputOutput>(size);
while (size-- > 0) {
long vertexId = in.readLong();
DataInputOutput dataInputOutput = config.createMessagesInputOutput();
dataInputOutput.readFields(in);
partitionMap.put(vertexId, dataInputOutput);
}
synchronized (map) {
map.put(partitionId, partitionMap);
}
}
示例14: purgeIntersectingClusterEntries
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
protected Long2ObjectOpenHashMap<LongArrayList> purgeIntersectingClusterEntries(
Long2ObjectOpenHashMap<LongArrayList> result) {
Long2ObjectOpenHashMap<LongArrayList> purgedResult = new Long2ObjectOpenHashMap<>();
Iterator<Long> resultIterator = result.keySet().iterator();
while (resultIterator.hasNext()) {
long uniqueCluster = resultIterator.next();
if (result.get(uniqueCluster).size() != 1) {
purgedResult.put(uniqueCluster, result.get(uniqueCluster));
}
}
return purgedResult;
}
示例15: synchronizedLong2ObjectOpenHashMapGet
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; //導入依賴的package包/類
@Benchmark
public void synchronizedLong2ObjectOpenHashMapGet(Context context) {
Long2ObjectOpenHashMap<Object> map = new Long2ObjectOpenHashMap<>();
synchronized (map) {
fastutilMapGet(context, map);
}
}