本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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");
}
示例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();
}
示例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();
}
示例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;
}