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


Java ByteArrays.grow方法代码示例

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


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

示例1: append

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
public void append(byte b) {
    if (size >= bytes.length - 1) {
        bytes = ByteArrays.grow(bytes, bytes.length + 1024);
    }
    switch (b) {
        case -1:
            bytes[size++] = -1;
            bytes[size++] = MINUS_CODE;
            break;
        case (byte) '\n':
            bytes[size++] = -1;
            bytes[size++] = NL_CODE;
            break;
        case (byte) '\r':
            bytes[size++] = -1;
            bytes[size++] = RETURN_CODE;
            break;
        default:
            bytes[size++] = b;
    }

}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:23,代码来源:LineBytesBuffer.java

示例2: dequeue

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
/** Dequeues an object from the queue in FIFO fashion. */
@SuppressWarnings("unchecked")
public synchronized T dequeue() throws IOException {
	final int length = byteDiskQueue.dequeueInt();
	fbaos.array = ByteArrays.grow(fbaos.array, length);
	byteDiskQueue.dequeue(fbaos.array, 0, length);
	size--;
	try {
		return (T)BinIO.loadObject(new FastByteArrayInputStream(fbaos.array, 0, length));
	}
	catch (final ClassNotFoundException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:15,代码来源:ObjectDiskQueue.java

示例3: readLineFrom

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
public boolean readLineFrom(FastBufferedInputStream stream) throws IOException {
    int start = 0, len;
    while ((len = stream.readLine(bytes, start, bytes.length - start)) == bytes.length - start) {
        start += len;
        bytes = ByteArrays.grow(bytes, bytes.length + 1024);
    }
    size = start + Math.max(len, 0);
    return !(size == 0 && len < 0);
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:10,代码来源:LineBytesBuffer.java

示例4: write

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
public void write( final int b ) {
	if ( position >= array.length ) array = ByteArrays.grow( array, position + 1, length );
	array[ position++ ] = (byte)b;
	if ( length < position ) length = position;
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:6,代码来源:FastByteArrayOutputStream.java

示例5: FileLinesList

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
/** Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set.
 *
 * @param filename a filename.
 * @param encoding an encoding.
 * @param bufferSize the buffer size for {@link FastBufferedInputStream}.
 * @param terminators a set of line terminators.
 */
public FileLinesList(final CharSequence filename, final String encoding, final int bufferSize, final EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException {
	this.bufferSize = bufferSize;
	this.terminators = terminators;
	this.filename = filename.toString();

	inputStream = new FastBufferedInputStream(new FileInputStream(this.filename), bufferSize);
	decoder = (charset = Charset.forName(encoding)).newDecoder();
	byte[] array = new byte[16];
	int count = 0, start, len;

	for(;;) {
		start = 0;
		while((len = inputStream.readLine(array, start, array.length - start, terminators)) == array.length - start) {
			start += len;
			array = ByteArrays.grow(array, array.length + 1);
		};

		if (len != -1) count++;
		else break;
	}

	size = count;
	byteBuffer = ByteBuffer.wrap(array);
	charBuffer = CharBuffer.wrap(new char[array.length]);

	inputStream.position(0);
	borders = new EliasFanoMonotoneLongBigList(count, inputStream.length(), new LongIterator() {
		long pos = 0;
		byte[] buffer = byteBuffer.array();

		@Override
		public boolean hasNext() {
			return pos < size;
		}

		@Override
		public long nextLong() {
			if (! hasNext()) throw new NoSuchElementException();
			pos++;
			try {
				final long result = inputStream.position();
				inputStream.readLine(buffer, terminators);
				return result;
			}
			catch (final IOException e) {
				throw new RuntimeException(e);
			}
		}
	});
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:58,代码来源:FileLinesList.java

示例6: FileLinesBigList

import it.unimi.dsi.fastutil.bytes.ByteArrays; //导入方法依赖的package包/类
/** Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set.
 *
 * @param filename a filename.
 * @param encoding an encoding.
 * @param bufferSize the buffer size for {@link FastBufferedInputStream}.
 * @param terminators a set of line terminators.
 */
public FileLinesBigList(final CharSequence filename, final String encoding, final int bufferSize, final EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException {
	this.bufferSize = bufferSize;
	this.terminators = terminators;
	this.filename = filename.toString();

	inputStream = new FastBufferedInputStream(new FileInputStream(this.filename), bufferSize);
	decoder = (charset = Charset.forName(encoding)).newDecoder();
	byte[] array = new byte[16];
	long count = 0;
	int start, len;

	for(;;) {
		start = 0;
		while((len = inputStream.readLine(array, start, array.length - start, terminators)) == array.length - start) {
			start += len;
			array = ByteArrays.grow(array, array.length + 1);
		};

		if (len != -1) count++;
		else break;
	}

	size = count;
	byteBuffer = ByteBuffer.wrap(array);
	charBuffer = CharBuffer.wrap(new char[array.length]);

	inputStream.position(0);
	borders = new EliasFanoMonotoneLongBigList(count, inputStream.length(), new LongIterator() {
		long pos = 0;
		byte[] buffer = byteBuffer.array();

		@Override
		public boolean hasNext() {
			return pos < size;
		}

		@Override
		public long nextLong() {
			if (! hasNext()) throw new NoSuchElementException();
			pos++;
			try {
				final long result = inputStream.position();
				inputStream.readLine(buffer, terminators);
				return result;
			}
			catch (final IOException e) {
				throw new RuntimeException(e);
			}
		}
	});
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:59,代码来源:FileLinesBigList.java


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