本文整理汇总了Java中it.unimi.dsi.fastutil.bytes.ByteBigArrays.set方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBigArrays.set方法的具体用法?Java ByteBigArrays.set怎么用?Java ByteBigArrays.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.bytes.ByteBigArrays
的用法示例。
在下文中一共展示了ByteBigArrays.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBigBytes
import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //导入方法依赖的package包/类
public void testBigBytes( byte[][] a ) throws IOException {
final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
file.deleteOnExit();
final long length = ByteBigArrays.length( a );
final byte[][] aShifted = ByteBigArrays.newBigArray( length + 1 );
ByteBigArrays.copy( a, 0, aShifted, 1, length );
for( int i = 0; i < 6; i++ ) {
file.delete();
switch(i) {
case 0: BinIO.storeBytes( a, file ); break;
case 1: BinIO.storeBytes( a, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
case 2: BinIO.storeBytes( a, new FileOutputStream( file ) ); break;
case 3: BinIO.storeBytes( aShifted, 1, length, file ); break;
case 4: BinIO.storeBytes( aShifted, 1, length, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
case 5: BinIO.storeBytes( aShifted, 1, length, new FileOutputStream( file ) ); break;
}
assertArrayEquals( a, BinIO.loadBytesBig( file ) );
byte[][] b = ByteBigArrays.newBigArray( length );
assertEquals( length, BinIO.loadBytes( file, b ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( file, b, 0, length ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b, 0, length ) );
assertArrayEquals( a, b );
byte[][] c = ByteBigArrays.newBigArray( length + 1 );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c ) );
assertEquals( 0, ByteBigArrays.get( c, length ) );
ByteBigArrays.copy( c, 0, b, 0, b.length );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c, 1, length ) );
assertEquals( 0, ByteBigArrays.get( c, 0 ) );
ByteBigArrays.copy( c, 1, b, 0, b.length );
assertArrayEquals( a, b );
ByteBigArrays.set( c, length, (byte)0 );
assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c ) );
assertEquals( 0, ByteBigArrays.get( c, length ) );
ByteBigArrays.copy( c, 0, b, 0, b.length );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c, 1, length ) );
assertEquals( 0, ByteBigArrays.get( c, 0 ) );
ByteBigArrays.copy( c, 1, b, 0, b.length );
assertArrayEquals( a, b );
}
}