本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongList类的典型用法代码示例。如果您正苦于以下问题:Java LongList类的具体用法?Java LongList怎么用?Java LongList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongList类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了LongList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValues
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
public List<LongList> getValues() {
return this.value;
// if (finalized) {
// // TODO: notwendig?
// List<LongList> temp = new LinkedList<LongList>();
// for (LongList il : this.value) {
// LongList temp_ = new LongArrayList();
// temp_.addAll(il);
// temp.add(temp_);
// }
// return temp;
// } else {
// return this.value;
// }
}
示例2: isLessThanMinUserSocialProofSize
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
private static boolean isLessThanMinUserSocialProofSize(
Map<Byte, Map<Long, LongList>> socialProofs,
int minUserSocialProofSize
) {
// the sum of tweet users and retweet users needs to be greater than a threshold
byte[] metadataSocialProofTypes = {2, 4};
long socialProofSizeSum = 0;
for (byte socialProofType: metadataSocialProofTypes) {
if (socialProofs.get(socialProofType) != null) {
socialProofSizeSum += socialProofs.get(socialProofType).size();
}
}
return socialProofSizeSum < minUserSocialProofSize;
}
示例3: testTopSecondDegreeByCountForUsersWithSmallGraph2
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例4: testTopSecondDegreeByCountForUsersWithSmallGraph3
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例5: testTopSecondDegreeByCountForMomentWithSmallGraph2
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例6: testTopSecondDegreeByCountForMomentWithSmallGraph3
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例7: buildTestGraph
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例8: buildRandomBipartiteGraph
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例9: buildSmallTestBipartiteGraph
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的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);
}
示例10: valueList
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
/** Commodity methods that exposes transparently either the data contained in the chunk,
* or the data obtained by using the chunk to index a list.
*
* @param values a list of values. Must be either an instance of {@link LongList}, or an instance of {@link LongBigList}. If it
* is not {@code null}, the data in the chunk is used to index this list and return a value. Otherwise, the data in the chunk
* is returned directly.
* @return a big list of longs representing the values associated with each element in the chunk.
*/
public LongBigList valueList(final LongIterable values) {
return new AbstractLongBigList() {
private final LongBigList valueList = values == null ? null : (values instanceof LongList ? LongBigLists.asBigList((LongList)values) : (LongBigList)values);
@Override
public long size64() {
return Chunk.this.size();
}
@Override
public long getLong(final long index) {
return valueList == null ? Chunk.this.data(index) : valueList.getLong(Chunk.this.data(index));
}
};
}
示例11: getWriteDeltaOffset
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
/**
* Estimates the number of bits required for the succinct delta representation from strictly incremental
* <code>list</code>. For details of the representation (see
* {@link org.pebble.core.encoding.OutputSuccinctStream#writeDelta(it.unimi.dsi.fastutil.longs.LongList, int) writeDelta}).
* @param list to encode. List must be strictly incremental with positives (including zero) values.
* @param valueBitSize fixed number of bits used to represent value in list to be encoded. It can be any value
* between 1bit and 63 bits.
* @return number of representation bits.
*/
public int getWriteDeltaOffset(final LongList list, final int valueBitSize) {
final LongIterator listIterator = list.iterator();
int offset = getWriteDeltaOffset(list.size());
if (listIterator.hasNext()) {
long value;
long deltaValue;
long lastValue = listIterator.nextLong();
offset += writeLongOffset(lastValue, valueBitSize);
while (listIterator.hasNext()) {
value = listIterator.nextLong();
deltaValue = value - lastValue - 1;
offset += getWriteDeltaOffset(deltaValue);
lastValue = value;
}
}
return offset;
}
示例12: itShouldWriteDeltaSuccinctRepresentationSuccessfully
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
@Test
public void itShouldWriteDeltaSuccinctRepresentationSuccessfully() throws Exception {
final int valueBitSize = 1;
final LongList list = new LongArrayList(new long[] {1L, 2L, 3L, 5L, 7L, 10L});
/**
* 6 1 0 0 1 1 2 Delta list.
* 7 1 1 1 2 2 3 Add 1 to ensure non zeros.
* 111 1 1 1 01 01 11 Binary representation.
* 3-11 1 1 1 2-0 2-0 2-1 Decimal Gamma Prefix and Binary Gamma Suffix.
* 11-11 1 1 1 01-0 01-0 01-1 Binary Gamma Prefix and Binary Gamma Suffix.
* 01111 1 1 1 0100 0100 0101 Delta Encoding.
*/
final String expectedOutput = "01111 1 1 1 0100 0100 0101".replace(" ", "");
final int expectedOffset = 20;
final Helper.Output out = getOutput();
final int offset = out.stream.writeDelta(list, valueBitSize);
out.close();
assertEquals(expectedOutput, toBinaryString(out.buffer, offset));
assertEquals(expectedOffset, offset);
}
示例13: whenRepetitionsItShouldWriteItsSuccinctRepresentationSuccessfully
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
@Test
public void whenRepetitionsItShouldWriteItsSuccinctRepresentationSuccessfully() throws Exception {
final LongList list = new LongArrayList(
new long[] {1L, 1L, 2L, 3L, 3L, 3L, 5L, 6L, 6L, 7L, 10L, 11L, 11L, 16L, 19L, 19L}
);
/**
* {(0, 2), (2, 3), (4, 2), (7, 2), (9, 2)} Repetitions Intervals.
* 5 0 0 1 1 1 0 2 0 1 0 Delta Representation.
* 6 1 1 2 2 2 1 3 1 2 1 Add 1 to ensure non zeros.
* 011 1 1 10 10 10 1 11 1 10 1 Binary representation.
* 3-10 1 1 2-0 2-0 2-0 1 2-1 1 2-0 1 Decimal Gamma Prefix and Binary Gamma Suffix
* 11-10 1 1 10-0 10-0 10-0 1 10-1 1 10-0 1 Binary Gamma Prefix and Binary Gamma Suffix
* 01110 1 1 0100 0100 0100 1 0101 1 0100 1 Delta Encoding
*/
final String expectedOutput = "01110 1 1 0100 0100 0100 1 0101 1 0100 1".replace(" ", "");
final int expectedOffset = 30;
final Helper.Output out = getOutput();
final int offset = out.stream.writeRepetitions(list);
out.close();
assertEquals(expectedOutput, toBinaryString(out.buffer, offset));
assertEquals(expectedOffset, offset);
}
示例14: whenThereIsIntervalsOnListItShouldGetExpectedOffsetSuccessfully
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
@Test
public void whenThereIsIntervalsOnListItShouldGetExpectedOffsetSuccessfully() {
final int valueBitSize = 3;
final LongList list = new LongArrayList(
new long[] {1L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 12L, 14L, 15L, 16L, 17L, 19L, 20L, 21L, 22L, 23L, 24L, 30L}
);
/**
* 3 [7, 8, 9, 10] [14, 15, 16, 17] [19, 20, 21, 22, 23, 24] Intervals from list.
* 3 [7, 10] [14, 17] [19, 24] Interval format.
* 3 [7, 0] [2, 0] [0, 2] Interval delta format.
* 4 7 1 3 1 1 3 Add 1 to ensure non zeros.
* 001 111 1 11 1 1 11 Binary representation.
* 3-00 111 1 2-1 1 1 2-1 Decimal Gamma Prefix and Binary Gamma Suffix.
* 11-00 111 1 01-1 1 1 01-1 Binary Gamma Prefix and Binary Gamma Suffix.
* 01100 111 1 0101 1 1 0101 Delta Encoding.
*/
final int expectedOffset = 19;
final LongOutputOffset outputOffset = new LongOutputOffset();
final int offset = outputOffset.getWriteIntervalsOffset(list, valueBitSize);
assertEquals(expectedOffset, offset);
}
示例15: whenThereIsIntervalsAtEndOnListItShouldGetExpectedOffsetSuccessfully
import it.unimi.dsi.fastutil.longs.LongList; //导入依赖的package包/类
@Test
public void whenThereIsIntervalsAtEndOnListItShouldGetExpectedOffsetSuccessfully() {
final int valueBitSize = 3;
final LongList list = new LongArrayList(
new long[] {1L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 12L, 14L, 15L, 16L, 17L, 19L, 20L, 21L, 22L, 23L, 24L}
);
/**
* 3 [7, 8, 9, 10] [14, 15, 16, 17] [19, 20, 21, 22, 23, 24] Intervals from list.
* 3 [7, 10] [14, 17] [19, 24] Interval format.
* 3 [7, 0] [2, 0] [0, 2] Interval delta format.
* 4 7 1 3 1 1 3 Add 1 to ensure non zeros.
* 001 111 1 11 1 1 11 Binary representation.
* 3-00 111 1 2-1 1 1 2-1 Decimal Gamma Prefix and Binary Gamma Suffix.
* 11-00 111 1 01-1 1 1 01-1 Binary Gamma Prefix and Binary Gamma Suffix.
* 01100 111 1 0101 1 1 0101 Delta Encoding.
*/
final int expectedOffset = 19;
final LongOutputOffset outputOffset = new LongOutputOffset();
final int offset = outputOffset.getWriteIntervalsOffset(list, valueBitSize);
assertEquals(expectedOffset, offset);
}