com.esotericsoftware.kryo.io.Input.fill()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中com.esotericsoftware.kryo.io.Input.fill()方法的一些代码示例,展示了Input.fill()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.fill()方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Input
类名称:Input
方法名:fill

Input.fill介绍

[英]Fills the buffer with more bytes. Can be overridden to fill the bytes from a source other than the InputStream.
[中]用更多字节填充缓冲区。可以重写以从InputStream以外的源填充字节。

代码示例

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** @param optional Try to fill the buffer with this many bytes.
 * @return the number of bytes remaining, but not more than optional, or -1 if the EOS was reached and the buffer is empty. */
private int optional (int optional) throws KryoException {
  int remaining = limit - position;
  if (remaining >= optional) return optional;
  optional = Math.min(optional, capacity);
  int count;
  // Try to fill the buffer.
  count = fill(buffer, limit, capacity - limit);
  if (count == -1) return remaining == 0 ? -1 : Math.min(remaining, optional);
  remaining += count;
  if (remaining >= optional) {
    limit += count;
    return optional;
  }
  // Was not enough, compact and try again.
  System.arraycopy(buffer, position, buffer, 0, remaining);
  total += position;
  position = 0;
  while (true) {
    count = fill(buffer, remaining, capacity - remaining);
    if (count == -1) break;
    remaining += count;
    if (remaining >= optional) break; // Enough has been read.
  }
  limit = remaining;
  return remaining == 0 ? -1 : Math.min(remaining, optional);
}

代码示例来源:origin: com.esotericsoftware/kryo

/** @param optional Try to fill the buffer with this many bytes.
 * @return the number of bytes remaining, but not more than optional, or -1 if the EOS was reached and the buffer is empty. */
private int optional (int optional) throws KryoException {
  int remaining = limit - position;
  if (remaining >= optional) return optional;
  optional = Math.min(optional, capacity);
  int count;
  // Try to fill the buffer.
  count = fill(buffer, limit, capacity - limit);
  if (count == -1) return remaining == 0 ? -1 : Math.min(remaining, optional);
  remaining += count;
  if (remaining >= optional) {
    limit += count;
    return optional;
  }
  // Was not enough, compact and try again.
  System.arraycopy(buffer, position, buffer, 0, remaining);
  total += position;
  position = 0;
  while (true) {
    count = fill(buffer, remaining, capacity - remaining);
    if (count == -1) break;
    remaining += count;
    if (remaining >= optional) break; // Enough has been read.
  }
  limit = remaining;
  return remaining == 0 ? -1 : Math.min(remaining, optional);
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** @param optional Try to fill the buffer with this many bytes.
 * @return the number of bytes remaining, but not more than optional, or -1 if the EOS was reached and the buffer is empty. */
private int optional (int optional) throws KryoException {
  int remaining = limit - position;
  if (remaining >= optional) return optional;
  optional = Math.min(optional, capacity);
  int count;
  // Try to fill the buffer.
  count = fill(buffer, limit, capacity - limit);
  if (count == -1) return remaining == 0 ? -1 : Math.min(remaining, optional);
  remaining += count;
  if (remaining >= optional) {
    limit += count;
    return optional;
  }
  // Was not enough, compact and try again.
  System.arraycopy(buffer, position, buffer, 0, remaining);
  total += position;
  position = 0;
  while (true) {
    count = fill(buffer, remaining, capacity - remaining);
    if (count == -1) break;
    remaining += count;
    if (remaining >= optional) break; // Enough has been read.
  }
  limit = remaining;
  return remaining == 0 ? -1 : Math.min(remaining, optional);
}

代码示例来源:origin: svn2github/kryo

/** @param optional Try to fill the buffer with this many bytes.
 * @return the number of bytes remaining, but not more than optional, or -1 if the EOS was reached and the buffer is empty. */
private int optional (int optional) throws KryoException {
  int remaining = limit - position;
  if (remaining >= optional) return optional;
  optional = Math.min(optional, capacity);
  int count;
  
  // Try to fill the buffer.
  count = fill(buffer, limit, capacity - limit);
  if (count == -1) return remaining == 0 ? -1 : Math.min(remaining, optional);
  remaining += count;
  if (remaining >= optional) {
    limit += count;
    return optional;
  }
  // Was not enough, compact and try again.
  System.arraycopy(buffer, position, buffer, 0, remaining);
  total += position;
  position = 0;
  while (true) {
    count = fill(buffer, remaining, capacity - remaining);
    if (count == -1) break;
    remaining += count;
    if (remaining >= optional) break; // Enough has been read.
  }
  limit = remaining;
  return remaining == 0 ? -1 : Math.min(remaining, optional);
}

代码示例来源:origin: com.esotericsoftware/kryo

protected int fill (byte[] buffer, int offset, int count) throws KryoException {
  if (chunkSize == -1) // No current chunk, expect a new chunk.
    readChunkSize();
  else if (chunkSize == 0) // End of chunks.
    return -1;
  int actual = super.fill(buffer, offset, Math.min(chunkSize, count));
  chunkSize -= actual;
  if (chunkSize == 0) readChunkSize(); // Read next chunk size.
  return actual;
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

protected int fill (byte[] buffer, int offset, int count) throws KryoException {
  if (chunkSize == -1) // No current chunk, expect a new chunk.
    readChunkSize();
  else if (chunkSize == 0) // End of chunks.
    return -1;
  int actual = super.fill(buffer, offset, Math.min(chunkSize, count));
  chunkSize -= actual;
  if (chunkSize == 0) readChunkSize(); // Read next chunk size.
  return actual;
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

protected int fill (byte[] buffer, int offset, int count) throws KryoException {
  if (chunkSize == -1) // No current chunk, expect a new chunk.
    readChunkSize();
  else if (chunkSize == 0) // End of chunks.
    return -1;
  int actual = super.fill(buffer, offset, Math.min(chunkSize, count));
  chunkSize -= actual;
  if (chunkSize == 0) readChunkSize(); // Read next chunk size.
  return actual;
}

代码示例来源:origin: svn2github/kryo

protected int fill (byte[] buffer, int offset, int count) throws KryoException {
  if (chunkSize == -1) // No current chunk, expect a new chunk.
    readChunkSize();
  else if (chunkSize == 0) // End of chunks.
    return -1;
  int actual = super.fill(buffer, offset, Math.min(chunkSize, count));
  chunkSize -= actual;
  if (chunkSize == 0) readChunkSize(); // Read next chunk size.
  return actual;
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

count = fill(buffer, limit, capacity - limit);
if (count == -1) throw new KryoException("Buffer underflow.");
remaining += count;
count = fill(buffer, remaining, capacity - remaining);
if (count == -1) {
  if (remaining >= required) break;

代码示例来源:origin: com.esotericsoftware/kryo-shaded

count = fill(buffer, limit, capacity - limit);
if (count == -1) throw new KryoException("Buffer underflow.");
remaining += count;
count = fill(buffer, remaining, capacity - remaining);
if (count == -1) {
  if (remaining >= required) break;

代码示例来源:origin: com.esotericsoftware/kryo

count = fill(buffer, limit, capacity - limit);
if (count == -1) throw new KryoException("Buffer underflow.");
remaining += count;
count = fill(buffer, remaining, capacity - remaining);
if (count == -1) {
  if (remaining >= required) break;

代码示例来源:origin: svn2github/kryo

count = fill(buffer, limit, capacity - limit);
if (count == -1) throw new KryoException("Buffer underflow.");
remaining += count;
count = fill(buffer, remaining, capacity - remaining);
if (count == -1) {
  if (remaining >= required) break;

相关文章

微信公众号

最新文章

更多