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


Java LongArrayList.wrap方法代码示例

本文整理汇总了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()));
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:10,代码来源:DateTimeColumn.java

示例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);

		}
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:28,代码来源:GV3CompressedFunctionTest.java

示例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);

		}
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:28,代码来源:GV3CompressedFunctionTest.java

示例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");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:48,代码来源:EliasFanoMonotoneLongBigListSpeedTest.java

示例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");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:48,代码来源:EliasFanoLongBigListSpeedTest.java

示例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);
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:7,代码来源:SparseRankTest.java


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