当前位置: 首页>>代码示例>>Java>>正文


Java LongList.add方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongList.add方法的典型用法代码示例。如果您正苦于以下问题:Java LongList.add方法的具体用法?Java LongList.add怎么用?Java LongList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.longs.LongList的用法示例。


在下文中一共展示了LongList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:33,代码来源:BipartiteGraphTestHelper.java

示例2: readLongDeltaItShouldReadExpectedValues

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void readLongDeltaItShouldReadExpectedValues() throws IOException {
    final LongList expectedValues = new LongArrayList(new long[] {17L, 4L, 6L});
    /**
     * 18        5     7     Increment one.
     * 10010     101   111   Binary representation.
     * 5-0010    3-01  3-11  Decimal Gamma Prefix and Binary Gamma Suffix.
     * 101-0010  11-01 11-11 Binary Gamma Prefix and Binary Gamma Suffix.
     * 001010010 01101 01111 Delta Encoding.
     */
    final Helper.Input input = getInput("001010010 01101 01111");
    final InputBitStream inputStream = new InputBitStream(input.buffer);
    final LongList values = new LongArrayList();

    for (int i = 0; i < expectedValues.size(); i++) {
        values.add(inputStream.readLongDelta());
    }

    assertEquals(expectedValues, values);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:21,代码来源:InputBitStreamReadDeltaTest.java

示例3: readLongGammaItShouldReadExpectedValues

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void readLongGammaItShouldReadExpectedValues() throws IOException {
    final LongList expectedValues = new LongArrayList(new long[] {17L, 4L, 6L});
    /**
     * 18        5     7     Increment one.
     * 10010     101   111   Binary representation.
     * 5-0010    3-01  3-11  Decimal Gamma Prefix and Binary Gamma Suffix.
     * 000010010 00101 00111 Gamma Encoding.
     */
    final Helper.Input input = getInput("000010010 00101 00111");
    final InputBitStream inputStream = new InputBitStream(input.buffer);
    final LongList values = new LongArrayList();

    for (int i = 0; i < expectedValues.size(); i++) {
        values.add(inputStream.readLongGamma());
    }

    assertEquals(expectedValues, values);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:20,代码来源:InputBitStreamReadGammaTest.java

示例4: itShouldReadExpectedValues

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void itShouldReadExpectedValues() throws IOException {
    final LongList expectedValues = new LongArrayList(new long[] {19L, Long.MAX_VALUE, -1});
    final int[] sizes = new int[] {5, 63, 64};
    final Helper.Input input = getInput(
        "10011" +
        "111111111111111111111111111111111111111111111111111111111111111" +
        "1111111111111111111111111111111111111111111111111111111111111111"
    );
    final InputBitStream inputStream = new InputBitStream(input.buffer);
    final LongList values = new LongArrayList();

    for (int i = 0; i < sizes.length; i++) {
        values.add(inputStream.readLong(sizes[i]));
    }

    assertEquals(expectedValues, values);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:19,代码来源:InputBitStreamReadLongTest.java

示例5: whenThereIsAnEncodedNonEmptyIntervalsListItShouldRecoverOriginalIntervalsSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenThereIsAnEncodedNonEmptyIntervalsListItShouldRecoverOriginalIntervalsSuccessfully()
    throws Exception
{
    Helper.Input input = getInput(
        "01100 000000000000000000000000000000000000000000000000000000000000111 1 0101 1 1 0101"
    );
    final LongList expectedList = new LongArrayList(
        new long[] {7L, 8L, 9L, 10L, 14L, 15L, 16L, 17L, 19L, 20L, 21L, 22L, 23L, 24L}
    );
    final LongList list = new LongArrayList();

    IntervalIterator intervalIterator = new IntervalIterator(
        DefaultParametersValues.LONG_BITS,
        DefaultParametersValues.DEFAULT_MIN_INTERVAL_SIZE,
        input.stream
    );
    while (intervalIterator.hasNext()) {
        list.add(intervalIterator.next());
    }

    assertEquals(expectedList, list);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:24,代码来源:IntervalIteratorTest.java

示例6: whenThereIsAnEncodedEmptyIntervalsListItShouldRecoverOriginalIntervalsSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenThereIsAnEncodedEmptyIntervalsListItShouldRecoverOriginalIntervalsSuccessfully() throws Exception {
    Helper.Input input = getInput("1");
    final LongList expectedList = new LongArrayList(new long[] {});
    final LongList list = new LongArrayList();

    IntervalIterator intervalIterator = new IntervalIterator(
        DefaultParametersValues.LONG_BITS,
        DefaultParametersValues.DEFAULT_MIN_INTERVAL_SIZE,
        input.stream
    );
    while (intervalIterator.hasNext()) {
        list.add(intervalIterator.next());
    }

    assertEquals(expectedList, list);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:18,代码来源:IntervalIteratorTest.java

示例7: whenReferenceListFirstElementsMatchesWithListShouldRecoverListSegmentOnReferenceListSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenReferenceListFirstElementsMatchesWithListShouldRecoverListSegmentOnReferenceListSuccessfully()
    throws Exception
{
    final Helper.Input input = getInput("0100 0100 1 01100");
    final int listIndex = 1;
    final LongList referenceList = new LongArrayList(new long[] {1L, 2L, 3L, 5L, 9L, 12L, 13L});
    final LongList expectedList = new LongArrayList(new long[] {1L, 2L, 3L, 5L});
    final LongList list = new LongArrayList();

    ReferenceIterator referenceIterator = new ReferenceIteratorBuilder(input, listIndex, referenceList).build();
    while (referenceIterator.hasNext()) {
        list.add(referenceIterator.next());
    }

    assertEquals(expectedList, list);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:18,代码来源:ReferenceIteratorTest.java

示例8: whenReferenceListLastElementsMatchesWithListShouldRecoverListSegmentOnReferenceListSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenReferenceListLastElementsMatchesWithListShouldRecoverListSegmentOnReferenceListSuccessfully()
    throws Exception
{
    final Helper.Input input = getInput("0100 01100 0 1 0101 1");
    final int listIndex = 1;
    final LongList referenceList = new LongArrayList(new long[] {0L, 2L, 3L, 5L, 9L, 12L, 13L});
    final LongList expectedList = new LongArrayList(new long[] {2L, 3L, 5L, 12L, 13L});
    final LongList list = new LongArrayList();

    ReferenceIterator referenceIterator = new ReferenceIteratorBuilder(input, listIndex, referenceList).build();
    while (referenceIterator.hasNext()) {
        list.add(referenceIterator.next());
    }

    assertEquals(expectedList, list);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:18,代码来源:ReferenceIteratorTest.java

示例9: whenThereIsAnEncodedRepetitionsListItShouldRecoverOriginalRepetitionsSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenThereIsAnEncodedRepetitionsListItShouldRecoverOriginalRepetitionsSuccessfully()
    throws Exception
{
    final int originalListSize = 16;
    Helper.Input input = getInput("01110 1 1 0100 0100 0100 1 0101 1 0100 1");
    /**
     * 1, 1, 2, 3, 3, 3, 5, 6, 6, 7, 10, 11, 11, 16, 19, 19 List from which the repetitions where extracted
     * 1, 0, 0, 1, 1, 0, 0, 1, 0, 0,  0,  1,  0,  0,  1,  0 Repetition flags
     */
    final LongList expectedRepetitions = new LongArrayList(
        new long[] {1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L}
    );
    final LongList repetitions = new LongArrayList();

    RepeatsIterator repeatsIterator = new RepeatsIterator(input.stream);
    for(int i = 0; i < originalListSize; i++) {
       repetitions.add(repeatsIterator.next());
    }

    assertEquals(expectedRepetitions, repetitions);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:23,代码来源:RepeatsIteratorTest.java

示例10: whenEncodedRepetitionsListIsEmptyItShouldRecoverOriginalRepetitionsSuccessfully

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void whenEncodedRepetitionsListIsEmptyItShouldRecoverOriginalRepetitionsSuccessfully()
    throws Exception
{
    final int originalListSize = 10;
    Helper.Input input = getInput("1");
    /**
     * 1, 2, 3, 5, 6, 7, 10, 11, 16, 19 List from which the repetitions where extracted
     * 0, 0, 0, 0, 0, 0,  0,  0,  0,  0 Repetition flags
     */
    final LongList expectedRepetitions = new LongArrayList(
        new long[] {0L, 0L, 0L, 0L, 0L, 0L, 0L ,0L ,0L, 0L}
    );
    final LongList repetitions = new LongArrayList();
    RepeatsIterator repeatsIterator = new RepeatsIterator(input.stream);
    for(int i = 0; i < originalListSize; i++) {
        repetitions.add(repeatsIterator.next());
    }

    assertEquals(expectedRepetitions, repetitions);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:22,代码来源:RepeatsIteratorTest.java

示例11: convertToLongList

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
public static LongList convertToLongList(OpenBitSet set) {
    LongList bits = new LongArrayList();
    long lastIndex = set.nextSetBit(0);
    while (lastIndex != -1) {
        bits.add(lastIndex);
        lastIndex = set.nextSetBit(lastIndex + 1);
    }
    return bits;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:10,代码来源:BitSetUtil.java

示例12: initialize

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Override
public void initialize(List<List<long[]>> tableSamplesList) {
    // Collect all column combinations that can be inserted.
    List<SimpleColumnCombination> combinations = new ArrayList<>();
    for (Map<SimpleColumnCombination, AD> hllsByColumnCombo : adByTable.values()) {
        combinations.addAll(hllsByColumnCombo.keySet());
    }
    for (int i = 0; i < combinations.size(); i++) {
        combinations.get(i).setIndex(i);
    }
    sampledInvertedIndex.setMaxId(combinations.size() - 1);

    // Now create according hashes from the table samples and initialize the inverted index with them.
    LongList samples = new LongArrayList();
    for (int table = 0; table < tableSamplesList.size(); table++) {
        Map<SimpleColumnCombination, AD> adByColumnCombinations = adByTable.get(table);
        if (adByColumnCombinations != null) {
            List<long[]> tableSamples = tableSamplesList.get(table);
            for (long[] sampleRow : tableSamples) {
                for (Map.Entry<SimpleColumnCombination, AD> entry : adByColumnCombinations.entrySet()) {
                    SimpleColumnCombination combination = entry.getKey();
                    long combinedHash = 0;
                    int[] columns = combination.getColumns();
                    boolean anyNull = false;
                    for (int i = 0; i < columns.length; i++) {
                        long hash = sampleRow[columns[i]];
                        if (anyNull = hash == HashedColumnStore.NULLHASH) break;
                        combinedHash = Long.rotateLeft(combinedHash, 1) ^ hash;
                    }
                    if (!anyNull) {
                        samples.add(combinedHash);
                    }
                }

            }
        }
    }
    sampledInvertedIndex.initialize(samples);
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:40,代码来源:CombinedInclusionTester.java

示例13: getRandomLeftNodeEdges

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Override
public EdgeIterator getRandomLeftNodeEdges(long leftNode, int numSamples, Random random) {
  LongList samples = new LongArrayList(numSamples);
  for (int i = 0; i < numSamples; i++) {
    LongList edges = leftSideGraph.get(leftNode);
    samples.add(edges.get(random.nextInt(edges.size())));
  }
  return new MockEdgeIterator(samples.iterator());
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:10,代码来源:StaticLeftIndexedBipartiteGraph.java

示例14: getRandomRightNodeEdges

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Override
public EdgeIterator getRandomRightNodeEdges(long rightNode, int numSamples, Random random) {
  LongList samples = new LongArrayList(numSamples);
  for (int i = 0; i < numSamples; i++) {
    LongList edges = rightSideGraph.get(rightNode);
    samples.add(edges.get(random.nextInt(edges.size())));
  }
  return new MockEdgeIterator(samples.iterator());
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:10,代码来源:StaticBipartiteGraph.java

示例15: itShouldDecompressLists

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void itShouldDecompressLists() throws IOException {
    final Input input = getInput(
        "1 1 1 01101 00101 0101 01100 1" +
        "0101 1 0100 0100 01100 0100 1 1 1 1"
    );
    final PebbleOffsetsStore offsetsStore = new LongListPebbleOffsetsStore(new long[] {0L, 23L});
    final PebbleBytesStore bytesStore = new BytesArrayPebbleBytesStore(input.buffer, offsetsStore);
    final int valueBitSize = 5;
    final LongList[] expectedLists = new LongList[] {
        new LongArrayList(new long[] {5L, 8L, 12L, 13L}),
        new LongArrayList(new long[] {5L, 5L, 5L, 8L, 12L, 12L, 12L, 12L, 12L, 13L})
    };
    final LongList[] lists = new LongList[expectedLists.length];
    LongList list;
    LongIterator iterator;

    for(int i = 0; i < lists.length; i++) {
        iterator = IncrementalListIterator.build(i, valueBitSize, bytesStore);
        lists[i] = list = new LongArrayList();
        while(iterator.hasNext()) {
            list.add(iterator.nextLong());
        }
    }

    assertEquals(
        Helper.<Long, LongList>translateToUtilsCollection(expectedLists),
        Helper.<Long, LongList>translateToUtilsCollection(lists)
    );
}
 
开发者ID:groupon,项目名称:pebble,代码行数:31,代码来源:IncrementalLongListsTest.java


注:本文中的it.unimi.dsi.fastutil.longs.LongList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。