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


Java LongList.size方法代码示例

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


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

示例1: 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

示例2: 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

示例3: convertToBitSet

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
public static OpenBitSet convertToBitSet(LongList list) {
    OpenBitSet set = new OpenBitSet(list.size());
    for (long l : list) {
        set.fastSet(l);
    }
    return set;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:8,代码来源:BitSetUtil.java

示例4: visitSpecificationLookupRequest

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Override
protected SpecificationLookupResponse visitSpecificationLookupRequest(final SpecificationLookupRequest request) {
  final LongList identifiers = new AbstractLongList() {

    private List<Long> _raw = request.getIdentifier();

    @Override
    public long getLong(int index) {
      return _raw.get(index);
    }

    @Override
    public int size() {
      return _raw.size();
    }

  };
  final Collection<ValueSpecification> specifications;
  if (identifiers.size() == 1) {
    specifications = Collections.singleton(getUnderlying().getValueSpecification(identifiers.getLong(0)));
  } else {
    final Long2ObjectMap<ValueSpecification> specificationMap = getUnderlying().getValueSpecifications(identifiers);
    specifications = new ArrayList<ValueSpecification>(specificationMap.size());
    for (Long identifier : identifiers) {
      specifications.add(specificationMap.get(identifier));
    }
  }
  final SpecificationLookupResponse response = new SpecificationLookupResponse(specifications);
  return response;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:31,代码来源:IdentifierMapServer.java

示例5: add

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
/**
 * Adds to the store the <code>list</code>. In case the store is full it will overwrite the oldest list on the
 * store.
 *
 * @param offset position of the <code>list</code> respect to the list of lists, starting from zero.
 * @param recursiveReferences number of recursive reference of the <code>list</code>.
 * @param list to append to the store.
 * @return true when the <code>list</code> is added to the store and false when is not.
 */
public boolean add(final int offset, final int recursiveReferences, final LongList list) {
    if (recursiveReferences <= maxRecursiveReferences && minListSize <= list.size()) {
        if (lists[index] != null) {
            referenceListIndex.removeListFromListsInvertedIndex(index, lists[index]);
        }
        this.recursiveReferences[index] = recursiveReferences;
        offsets[index] = offset;
        lists[index] = new LongArrayList(list);
        referenceListIndex.addListIntoListsInvertedIndex(index, lists[index]);
        index = (index + 1) % offsets.length;
        return true;
    }
    return false;
}
 
开发者ID:groupon,项目名称:pebble,代码行数:24,代码来源:LongReferenceListsStore.java

示例6: readLongUnaryItShouldReadExpectedValues

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Test
public void readLongUnaryItShouldReadExpectedValues() throws IOException {
    final LongList expectedValues = new LongArrayList(new long[] {17L, 4L, 6L});
    final Helper.Input input = getInput("00000000000000001 0001 000001");
    final InputBitStream inputStream = new InputBitStream(input.buffer);
    final LongList values = new LongArrayList();

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

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

示例7: main

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
public static void main(final String[] arg) throws IOException, JSAPException, ClassNotFoundException {

		final SimpleJSAP jsap = new SimpleJSAP(ListSpeedTest.class.getName(), "Test the speed of a list",
				new Parameter[] {
					new Switch("random", 'r', "random", "Do a random test on at most 1 million strings."),
					new UnflaggedOption("list", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised list.")
		});

		JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final String listName = jsapResult.getString("list");

		final LongList list = (LongList)BinIO.loadObject(listName);
		long total = 0;
		int n = list.size();
		for(int k = 13; k-- != 0;) {
			long time = -System.currentTimeMillis();
			for(int i = 0; i < n; i++) {
				list.getLong(i);
				if (i++ % 100000 == 0) System.out.print('.');
			}
			System.out.println();
			time += System.currentTimeMillis();
			if (k < 10) total += time;
			System.out.println(time / 1E3 + "s, " + (time * 1E3) / n + " \u00b5s/item");
		}
		System.out.println("Average: " + Util.format(total / 10E3) + "s, " + Util.format((total * 1E3) / (10 * n)) + " \u00b5s/item");
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:30,代码来源:ListSpeedTest.java

示例8: getLong

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
@Override
public long getLong(int i) {
    for (LongList list : lists) {
        if (i < list.size()) {
            return list.getLong(i);
        }
        i -= list.size();
    }
    throw new ArrayIndexOutOfBoundsException();
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:11,代码来源:MultiListsViewLongList.java

示例9: executeStrippedPartitionGenerationTask

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
private void executeStrippedPartitionGenerationTask(int i) {

        StrippedPartition sp = new StrippedPartition(i);
        this.returnValue.add(sp);

        Map<String, LongList> toItterate = this.translationMaps.get(i);

        for (LongList it : toItterate.values()) {

            if (it.size() > 1) {
                sp.addElement(it);
            }

        }

        // Nach getaner Arbeit aufräumen
        this.translationMaps.get(i).clear();
    }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:19,代码来源:StrippedPartitionGenerator.java

示例10: getWriteIntervalsOffset

import it.unimi.dsi.fastutil.longs.LongList; //导入方法依赖的package包/类
/**
 * Estimates the number of bits required for the succinct intervals representation from strictly incremental
 * <code>list</code>. For details of the representation (see
 * {@link org.pebble.core.encoding.OutputSuccinctStream#writeIntervals(it.unimi.dsi.fastutil.longs.LongList, int) writeIntervals}).
 * @param list from which it will extracts the intervals 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 getWriteIntervalsOffset(final LongList list, final int valueBitSize) {
    int offset = 0;
    intervalsBuffer.clear();
    if (list.size() >= minIntervalSize) {
        LongIterator listIterator = list.iterator();
        int intervalInitialIndex = 0;
        int index = 1;
        long lastValue = listIterator.nextLong();
        long value;
        long deltaValue;
        intervalsBuffer.clear();
        while (listIterator.hasNext()) {
            value = listIterator.nextLong();
            deltaValue = value - lastValue;
            if (deltaValue > 1) {
                if (index - intervalInitialIndex >= minIntervalSize) {
                    intervalsBuffer.add(intervalInitialIndex);
                    intervalsBuffer.add(index - intervalInitialIndex);
                }
                intervalInitialIndex = index;
            }
            lastValue = value;
            index++;
        }
        if (index - intervalInitialIndex >= minIntervalSize) {
            intervalsBuffer.add(intervalInitialIndex);
            intervalsBuffer.add(index - intervalInitialIndex);
        }
        offset += getWriteDeltaOffset(intervalsBuffer.size() / 2);
        if (!intervalsBuffer.isEmpty()) {
            IntIterator intervalIterator = intervalsBuffer.iterator();
            intervalInitialIndex = intervalIterator.nextInt();
            index = 0;
            listIterator = list.iterator();
            boolean firstWrite = true;
            while(true) {
                value = listIterator.nextLong();
                if (index == intervalInitialIndex) {
                    listIterator.remove();
                    if (firstWrite) {
                        offset += writeLongOffset(value, valueBitSize);
                        firstWrite = false;
                    } else {
                        deltaValue = value - lastValue - 2;
                        offset += getWriteDeltaOffset(deltaValue);
                    }
                    intervalInitialIndex = intervalIterator.nextInt();
                    offset += getWriteDeltaOffset(intervalInitialIndex - minIntervalSize);
                    while (--intervalInitialIndex > 0) {
                        value = listIterator.nextLong();
                        listIterator.remove();
                        index++;
                    }
                    lastValue = value;
                    if (!intervalIterator.hasNext()) {
                        break;
                    }
                    intervalInitialIndex = intervalIterator.nextInt();
                }
                index++;
            }
        }
    } else {
        offset += getWriteDeltaOffset(0);
    }
    return offset;
}
 
开发者ID:groupon,项目名称:pebble,代码行数:78,代码来源:LongOutputOffset.java


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