本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongArrayList.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java LongArrayList.wrap方法的具体用法?Java LongArrayList.wrap怎么用?Java LongArrayList.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.longs.LongArrayList
的用法示例。
在下文中一共展示了LongArrayList.wrap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unique
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
@Override
public DateTimeColumn unique() {
LongSet ints = new LongOpenHashSet(data.size());
for (long i : data) {
ints.add(i);
}
return new DateTimeColumn(name() + " Unique values",
LongArrayList.wrap(ints.toLongArray()));
}
示例2: testUniformNumbers
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUniformNumbers() throws IOException, ClassNotFoundException {
// TODO: restore working codec for size 1
for (final int maxLength : new int[] { 2, 3, 4, 8, 16, 32, 64 }) {
for (final int size : new int[] { 0, 1000, 10000 }) {
final String[] s = new String[size];
for (int i = s.length; i-- != 0;)
s[i] = Integer.toString(i);
final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
final long[] v = new long[size];
for (int i = 0; i < size; i++) v[i] = r.nextInt(maxLength);
final Codec codec = new Codec.Huffman();
final LongArrayList values = LongArrayList.wrap(v);
GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(codec).transform(TransformationStrategies.utf16()).values(values).build();
check(size, s, mph, v);
final File temp = File.createTempFile(getClass().getSimpleName(), "test");
temp.deleteOnExit();
BinIO.storeObject(mph, temp);
mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);
check(size, s, mph, v);
}
}
}
示例3: testUniformBinary
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUniformBinary() throws IOException, ClassNotFoundException {
// TODO: restore working codec for size 1
for (final int maxLength : new int[] { 2, 3, 4, 8, 16, 32, 64 }) {
for (final int size : new int[] { 0, 1000, 10000 }) {
final String[] s = new String[size];
for (int i = s.length; i-- != 0;)
s[i] = Integer.toString(i);
final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
final long[] v = new long[size];
for (int i = 0; i < size; i++) v[i] = r.nextInt(maxLength);
final Codec codec = new Codec.Binary();
final LongArrayList values = LongArrayList.wrap(v);
GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(codec).transform(TransformationStrategies.utf16()).values(values).build();
check(size, s, mph, v);
final File temp = File.createTempFile(getClass().getSimpleName(), "test");
temp.deleteOnExit();
BinIO.storeObject(mph, temp);
mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);
check(size, s, mph, v);
}
}
}
示例4: main
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {
final SimpleJSAP jsap = new SimpleJSAP(EliasFanoMonotoneLongBigListSpeedTest.class.getName(), "Tests the speed Elias-Fano monotone lists.",
new Parameter[] {
new UnflaggedOption("numElements", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of elements."),
new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
new FlaggedOption("bulk", JSAP.INTSIZE_PARSER, "10", JSAP.NOT_REQUIRED, 'b', "bulk", "The number of positions to read with the bulk method"),
});
final JSAPResult jsapResult = jsap.parse(arg);
if (jsap.messagePrinted()) return;
final int numElements = jsapResult.getInt("numElements");
final double density = jsapResult.getDouble("density");
final int numPos = jsapResult.getInt("numPos");
final int bulk = jsapResult.getInt("bulk");
final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
final IntArrayList list = new IntArrayList(numElements);
for(long i = numElements; i-- != 0;) list.add(random.nextDouble() < density ? 0 : 100);
final int[] position = new int[numPos];
for(int i = numPos; i-- != 0;) position[i] = (random.nextInt() & 0x7FFFFFFF) % (numElements - bulk);
final long[] elements = new long[list.size()];
elements[0] = list.getInt(0);
for(int i = 1; i < list.size(); i++) elements[i] = list.getInt(i) + elements[i - 1];
final EliasFanoMonotoneLongBigList eliasFanoMonotoneLongBigList = new EliasFanoMonotoneLongBigList(LongArrayList.wrap(elements));
long time;
System.err.println("getLong():");
for(int k = 10; k-- != 0;) {
time = - System.nanoTime();
for(int i = 0; i < numPos; i++) eliasFanoMonotoneLongBigList.getLong(position[i]);
time += System.nanoTime();
System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/element");
}
final long[] dest = new long[bulk];
System.err.println("get():");
for(int k = 10; k-- != 0;) {
time = - System.nanoTime();
for(int i = 0; i < numPos; i++) eliasFanoMonotoneLongBigList.get(position[i], dest);
time += System.nanoTime();
System.err.println(time / 1E9 + "s, " + time / (double)(numPos * bulk) + " ns/element");
}
}
示例5: main
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {
final SimpleJSAP jsap = new SimpleJSAP(EliasFanoLongBigListSpeedTest.class.getName(), "Tests the speed of Elias-Fano compressed lists.",
new Parameter[] {
new UnflaggedOption("numElements", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of elements."),
new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
new FlaggedOption("bulk", JSAP.INTSIZE_PARSER, "10", JSAP.NOT_REQUIRED, 'b', "bulk", "The number of positions to read with the bulk method"),
});
final JSAPResult jsapResult = jsap.parse(arg);
if (jsap.messagePrinted()) return;
final int numElements = jsapResult.getInt("numElements");
final double density = jsapResult.getDouble("density");
final int numPos = jsapResult.getInt("numPos");
final int bulk = jsapResult.getInt("bulk");
final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
final IntArrayList list = new IntArrayList(numElements);
for(long i = numElements; i-- != 0;) list.add(random.nextDouble() < density ? 0 : 100);
final int[] position = new int[numPos];
for(int i = numPos; i-- != 0;) position[i] = (random.nextInt() & 0x7FFFFFFF) % (numElements - bulk);
final long[] elements = new long[list.size()];
elements[0] = list.getInt(0);
for(int i = 1; i < list.size(); i++) elements[i] = list.getInt(i) + elements[i - 1];
final EliasFanoLongBigList eliasFanoLongBigList = new EliasFanoLongBigList(LongArrayList.wrap(elements));
long time;
System.err.println("getLong():");
for(int k = 10; k-- != 0;) {
time = - System.nanoTime();
for(int i = 0; i < numPos; i++) eliasFanoLongBigList.getLong(position[i]);
time += System.nanoTime();
System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/element");
}
final long[] dest = new long[bulk];
System.err.println("get():");
for(int k = 10; k-- != 0;) {
time = - System.nanoTime();
for(int i = 0; i < numPos; i++) eliasFanoLongBigList.get(position[i], dest);
time += System.nanoTime();
System.err.println(time / 1E9 + "s, " + time / (double)(numPos * bulk) + " ns/element");
}
}
示例6: testGetRank
import it.unimi.dsi.fastutil.longs.LongArrayList; //导入方法依赖的package包/类
@Test
public void testGetRank() {
SparseSelect select = new SparseSelect(LongArrayList.wrap(new long[] { 0, 48, 128 }));
SparseRank rank = select.getRank();
assertRankAndSelect(rank, select);
}