本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongArrayList类的典型用法代码示例。如果您正苦于以下问题:Java LongArrayList类的具体用法?Java LongArrayList怎么用?Java LongArrayList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongArrayList类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了LongArrayList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: concat
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
public static String concat(LongArrayList longs, String separator) {
if (longs == null)
return "";
StringBuilder buffer = new StringBuilder();
for (long longValue : longs) {
buffer.append(longValue);
buffer.append(separator);
}
if (buffer.length() > separator.length())
buffer.delete(buffer.length() - separator.length(), buffer.length());
return buffer.toString();
}
示例2: calculateCondition
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
protected void calculateCondition(ColumnCombinationBitset partialUnique,
Map<ColumnCombinationBitset, PositionListIndex> currentLevel,
ColumnCombinationBitset conditionColumn,
PositionListIndex conditionPLI)
throws AlgorithmExecutionException {
List<LongArrayList> unsatisfiedClusters = new LinkedList<>();
//check which conditions hold
List<LongArrayList>
conditions =
this.calculateConditions(this.algorithm.getPLI(partialUnique),
conditionPLI,
this.algorithm.frequency,
unsatisfiedClusters);
if (!unsatisfiedClusters.isEmpty()) {
currentLevel.put(conditionColumn, new PositionListIndex(unsatisfiedClusters));
}
ResultSingleton resultSingleton = ResultSingleton.getInstance();
for (LongArrayList condition : conditions) {
List<ConditionEntry> conditionEntries = new LinkedList<>();
conditionEntries.add(new ConditionEntry(conditionColumn, condition));
resultSingleton.addConditionToResult(partialUnique, conditionEntries);
}
}
示例3: testCalculateConditions
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testCalculateConditions() throws Exception {
//Setup
PositionListIndex uniquePLI = fixture.getUniquePLIForConditionTest();
PositionListIndex conditionPLI = fixture.getConditionPLIForConditionTest();
List<LongArrayList> expectedConditions = fixture.getExpectedConditions();
//Execute functionality
List<LongArrayList> unsatisfiedClusters = new LinkedList<>();
AndConditionTraverser traverser = new AndConditionTraverser(new Dcucc());
List<LongArrayList>
actualConditions =
traverser
.calculateConditions(uniquePLI, conditionPLI, fixture.getFrequency(),
unsatisfiedClusters);
//Check result
assertThat(actualConditions,
IsIterableContainingInAnyOrder.containsInAnyOrder(
expectedConditions.toArray()
)
);
assertEquals(unsatisfiedClusters.get(0), fixture.getExpectedUnsatisfiedClusters().get(0));
}
示例4: concat
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
public static String concat(LongArrayList longs, String separator) {
if (longs == null)
return "";
StringBuilder buffer = new StringBuilder();
for (long longValue : longs) {
buffer.append(longValue);
buffer.append(separator);
}
if (buffer.length() > separator.length())
buffer.delete(buffer.length() - separator.length(), buffer.length());
return buffer.toString();
}
示例5: pickTopSocialProofs
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
/**
* Pick the top social proofs for each RHS node
*/
public static Map<Byte, ConnectingUsersWithMetadata> pickTopSocialProofs(
SmallArrayBasedLongToDoubleMap[] socialProofs){
Map<Byte, ConnectingUsersWithMetadata> results = new HashMap<>();
for (int i = 0; i < socialProofs.length; i++) {
SmallArrayBasedLongToDoubleMap socialProof = socialProofs[i];
if (socialProof != null) {
if (socialProof.size() > 1) {
socialProof.sort();
}
socialProof.trim(socialProof.size());
results.put((byte)i, new ConnectingUsersWithMetadata(
new LongArrayList(socialProof.keys()),
new LongArrayList(socialProof.metadata())
));
}
}
return results;
}
示例6: pickTopSocialProofs
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
/**
* Pick the top social proofs for each RHS node
*/
private Map<Byte, ConnectingUsersWithMetadata> pickTopSocialProofs(
SmallArrayBasedLongToDoubleMap[] socialProofs,
byte[] validSocialProofs
) {
Map<Byte, ConnectingUsersWithMetadata> results = new HashMap<Byte, ConnectingUsersWithMetadata>();
int length = validSocialProofs.length;
for (int i = 0; i < length; i++) {
SmallArrayBasedLongToDoubleMap socialProof = socialProofs[validSocialProofs[i]];
if (socialProof != null) {
if (socialProof.size() > 1) {
socialProof.sort();
}
socialProof.trim(socialProof.size());
results.put((byte) i, new ConnectingUsersWithMetadata(
new LongArrayList(socialProof.keys()),
new LongArrayList(socialProof.metadata())
));
}
}
return results;
}
示例7: run
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
/**
* Runs PageRank, either until the max number of iterations has been reached or the L1 norm of
* the difference between PageRank vectors drops below the tolerance.
*
* @return number of iterations that was actually run
*/
public int run() {
LongArrayList noOuts = new LongArrayList();
LongIterator iter = nodes.iterator();
while (iter.hasNext()) {
long v = iter.nextLong();
if (graph.getOutDegree(v) == 0) {
noOuts.add(v);
}
}
double dampingAmount = (1.0 - dampingFactor) / nodeCount;
prVector = new double[(int) (maxNodeId + 1)];
nodes.forEach(v -> prVector[(int) (long) v] = 1.0 / nodeCount);
int i = 0;
while (i < this.maxIterations && normL1 > tolerance) {
iterate(dampingAmount, noOuts);
i++;
}
return i;
}
示例8: MultiThreadedPageRank
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
/**
* Constructs this object for running PageRank over a directed graph.
*
* @param graph the directed graph
* @param nodes nodes in the graph
* @param maxNodeId maximum node id
* @param dampingFactor damping factor
* @param maxIterations maximum number of iterations to run
* @param tolerance L1 norm threshold for convergence
* @param threads number of threads
*/
public MultiThreadedPageRank(OutIndexedDirectedGraph graph, LongArrayList nodes,
long maxNodeId, double dampingFactor, int maxIterations,
double tolerance, int threads) {
if (maxNodeId > Integer.MAX_VALUE) {
throw new UnsupportedOperationException("maxNodeId exceeds Integer.MAX_VALUE!");
}
this.graph = graph;
this.nodes = nodes;
this.maxNodeId = maxNodeId;
this.dampingFactor = dampingFactor;
this.nodeCount = nodes.size();
this.maxIterations = maxIterations;
this.tolerance = tolerance;
this.threads = threads;
}
示例9: testInternalIdToLongIterator
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testInternalIdToLongIterator() {
LongToInternalIntBiMap nodesToIndexBiMap =
new ArrayBasedLongToInternalIntBiMap(10, 0.5, -1, -1L, nullStatsReceiver);
int n = 7;
int[] expectedIndices = new int[n];
long[] expectedEntries = new long[n];
for (int i = 0; i < n; i++) {
expectedIndices[i] = nodesToIndexBiMap.put(i);
expectedEntries[i] = (long) i;
}
IntIterator intIterator = new IntArrayList(expectedIndices).iterator();
InternalIdToLongIterator internalIdToLongIterator =
new InternalIdToLongIterator(nodesToIndexBiMap, new IdentityEdgeTypeMask());
internalIdToLongIterator.resetWithIntIterator(new WithEdgeMetadataIntIteratorImpl(intIterator));
assertEquals(new LongArrayList(expectedEntries), new LongArrayList(internalIdToLongIterator));
}
示例10: testTopSecondDegreeByCountForUsersWithSmallGraph2
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testTopSecondDegreeByCountForUsersWithSmallGraph2() throws Exception {
// Test 2: Test with small maxNumResults
LongList metadata = new LongArrayList(new long[]{0, 0, 0});
HashMap<Byte, ConnectingUsersWithMetadata> socialProofFor3 = new HashMap<> ();
socialProofFor3.put((byte) 1, new ConnectingUsersWithMetadata(new LongArrayList(new long[]{1, 2, 3}), metadata));
Map<Byte, Integer> minUserPerSocialProof = new HashMap<>();
List<UserRecommendationInfo> expectedTopResults = new ArrayList<>();
byte[] socialProofTypes = new byte[] {0, 1, 2, 3};
RecommendationStats expectedTopSecondDegreeByCountStats = new RecommendationStats(5, 6, 17, 2, 4, 0);
int maxNumResults = 1;
expectedTopResults.clear();
expectedTopResults.add(new UserRecommendationInfo(3, 3.0, socialProofFor3));
testTopSecondDegreeByCountHelper(
maxNumResults,
minUserPerSocialProof,
socialProofTypes,
expectedTopResults,
expectedTopSecondDegreeByCountStats);
}
示例11: testTopSecondDegreeByCountForUsersWithSmallGraph3
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testTopSecondDegreeByCountForUsersWithSmallGraph3() throws Exception {
// Test 3: Test limiting minimum number of users per social proof
LongList metadata = new LongArrayList(new long[]{0, 0, 0});
HashMap<Byte, ConnectingUsersWithMetadata> socialProofFor3 = new HashMap<> ();
socialProofFor3.put((byte) 1, new ConnectingUsersWithMetadata(new LongArrayList(new long[]{1, 2, 3}), metadata));
Map<Byte, Integer> minUserPerSocialProof = new HashMap<>();
List<UserRecommendationInfo> expectedTopResults = new ArrayList<>();
byte[] socialProofTypes = new byte[] {0, 1, 2, 3};
RecommendationStats expectedTopSecondDegreeByCountStats = new RecommendationStats(5, 6, 17, 2, 4, 0);
int maxNumResults = 3;
minUserPerSocialProof.put((byte) 1, 3); // 3 users per proof
expectedTopResults.clear();
expectedTopResults.add(new UserRecommendationInfo(3, 3.0, socialProofFor3));
testTopSecondDegreeByCountHelper(
maxNumResults,
minUserPerSocialProof,
socialProofTypes,
expectedTopResults,
expectedTopSecondDegreeByCountStats);
}
示例12: testTopSecondDegreeByCountForMomentWithSmallGraph2
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testTopSecondDegreeByCountForMomentWithSmallGraph2() throws Exception {
// Test 2: Test with small maxNumResults
LongList metadata3 = new LongArrayList(new long[]{0, 0, 0});
HashMap<Byte, ConnectingUsersWithMetadata> socialProofFor3 = new HashMap<> ();
socialProofFor3.put((byte) 1, new ConnectingUsersWithMetadata(new LongArrayList(new long[]{1, 2, 3}), metadata3));
Map<Byte, Integer> minUserPerSocialProof = new HashMap<>();
List<TopSecondDegreeByCountRecommendationInfo> expectedTopResults = new ArrayList<>();
byte[] socialProofTypes = new byte[] {0, 1, 2, 3};
RecommendationStats expectedTopSecondDegreeByCountStats = new RecommendationStats(5, 6, 17, 2, 4, 0);
int maxNumResults = 1;
expectedTopResults.clear();
expectedTopResults.add(new MomentRecommendationInfo(3,3.0, socialProofFor3));
testTopSecondDegreeByCountHelper(
maxNumResults,
minUserPerSocialProof,
socialProofTypes,
expectedTopResults,
expectedTopSecondDegreeByCountStats);
}
示例13: testTopSecondDegreeByCountForMomentWithSmallGraph3
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的package包/类
@Test
public void testTopSecondDegreeByCountForMomentWithSmallGraph3() throws Exception {
// Test 3: Test limiting minimum number of minimum per social proof
LongList metadata3 = new LongArrayList(new long[]{0, 0, 0});
HashMap<Byte, ConnectingUsersWithMetadata> socialProofFor3 = new HashMap<> ();
socialProofFor3.put((byte) 1, new ConnectingUsersWithMetadata(new LongArrayList(new long[]{1, 2, 3}), metadata3));
Map<Byte, Integer> minUserPerSocialProof = new HashMap<>();
List<TopSecondDegreeByCountRecommendationInfo> expectedTopResults = new ArrayList<>();
byte[] socialProofTypes = new byte[] {0, 1, 2, 3};
RecommendationStats expectedTopSecondDegreeByCountStats = new RecommendationStats(5, 6, 17, 2, 4, 0);
int maxNumResults = 3;
minUserPerSocialProof.put((byte) 1, 3); // 3 moments per proof
expectedTopResults.clear();
expectedTopResults.add(new MomentRecommendationInfo(3,3.0, socialProofFor3));
testTopSecondDegreeByCountHelper(
maxNumResults,
minUserPerSocialProof,
socialProofTypes,
expectedTopResults,
expectedTopSecondDegreeByCountStats);
}
示例14: buildTestGraph
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的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);
}
示例15: buildRandomBipartiteGraph
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入依赖的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);
}