當前位置: 首頁>>代碼示例>>Java>>正文


Java SizeOf類代碼示例

本文整理匯總了Java中libcore.io.SizeOf的典型用法代碼示例。如果您正苦於以下問題:Java SizeOf類的具體用法?Java SizeOf怎麽用?Java SizeOf使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SizeOf類屬於libcore.io包,在下文中一共展示了SizeOf類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeNewString

import libcore.io.SizeOf; //導入依賴的package包/類
/**
 * Write String {@code object} into the receiver. It is assumed the
 * String has not been dumped yet. Returns the handle for this object (String) which is dumped here.
 * Strings are saved encoded with {@link DataInput modified UTF-8}.
 *
 * @param object
 *            the string to dump.
 * @return the handle assigned to the String being dumped
 *
 * @throws IOException
 *             If an IO exception happened when writing the String.
 */
private int writeNewString(String object, boolean unshared) throws IOException {
    long count = ModifiedUtf8.countBytes(object, false);
    byte[] buffer;
    int offset = 0;
    if (count <= 0xffff) {
        buffer = new byte[1 + SizeOf.SHORT + (int) count];
        buffer[offset++] = TC_STRING;
        Memory.pokeShort(buffer, offset, (short) count, ByteOrder.BIG_ENDIAN);
        offset += SizeOf.SHORT;
    } else {
        buffer = new byte[1 + SizeOf.LONG + (int) count];
        buffer[offset++] = TC_LONGSTRING;
        Memory.pokeLong(buffer, offset, count, ByteOrder.BIG_ENDIAN);
        offset += SizeOf.LONG;
    }
    ModifiedUtf8.encode(buffer, offset, object);
    output.write(buffer, 0, buffer.length);

    int handle = nextHandle();
    if (!unshared) {
        objectsWritten.put(object, handle);
    }

    return handle;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:38,代碼來源:ObjectOutputStream.java

示例2: setSeed

import libcore.io.SizeOf; //導入依賴的package包/類
/**
 * Seeds this {@code SecureRandom} instance with the specified eight-byte
 * {@code seed}. <a href="#insecure_seed">Seeding {@code SecureRandom} may
 * be insecure</a>.
 */
@Override
public void setSeed(long seed) {
    if (seed == 0) {    // skip call from Random
        return;
    }
    byte[] byteSeed = new byte[SizeOf.LONG];
    Memory.pokeLong(byteSeed, 0, seed, ByteOrder.BIG_ENDIAN);
    setSeed(byteSeed);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:15,代碼來源:SecureRandom.java

示例3: compact

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public ShortBuffer compact() {
    if (byteBuffer.isReadOnly()) {
        throw new ReadOnlyBufferException();
    }
    byteBuffer.limit(limit * SizeOf.SHORT);
    byteBuffer.position(position * SizeOf.SHORT);
    byteBuffer.compact();
    byteBuffer.clear();
    position = limit - position;
    limit = capacity;
    mark = UNSET_MARK;
    return this;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:15,代碼來源:ByteBufferAsShortBuffer.java

示例4: get

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public short get() {
    if (position == limit) {
        throw new BufferUnderflowException();
    }
    return byteBuffer.getShort(position++ * SizeOf.SHORT);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:8,代碼來源:ByteBufferAsShortBuffer.java

示例5: put

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public ShortBuffer put(short c) {
    if (position == limit) {
        throw new BufferOverflowException();
    }
    byteBuffer.putShort(position++ * SizeOf.SHORT, c);
    return this;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:9,代碼來源:ByteBufferAsShortBuffer.java

示例6: slice

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public ShortBuffer slice() {
    byteBuffer.limit(limit * SizeOf.SHORT);
    byteBuffer.position(position * SizeOf.SHORT);
    ByteBuffer bb = byteBuffer.slice().order(byteBuffer.order());
    ShortBuffer result = new ByteBufferAsShortBuffer(bb);
    byteBuffer.clear();
    return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:10,代碼來源:ByteBufferAsShortBuffer.java

示例7: get

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public float get() {
    if (position == limit) {
        throw new BufferUnderflowException();
    }
    return byteBuffer.getFloat(position++ * SizeOf.FLOAT);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:8,代碼來源:ByteBufferAsFloatBuffer.java

示例8: put

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public FloatBuffer put(float[] src, int srcOffset, int floatCount) {
    byteBuffer.limit(limit * SizeOf.FLOAT);
    byteBuffer.position(position * SizeOf.FLOAT);
    if (byteBuffer instanceof DirectByteBuffer) {
        ((DirectByteBuffer) byteBuffer).put(src, srcOffset, floatCount);
    } else {
        ((ByteArrayBuffer) byteBuffer).put(src, srcOffset, floatCount);
    }
    this.position += floatCount;
    return this;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:13,代碼來源:ByteBufferAsFloatBuffer.java

示例9: slice

import libcore.io.SizeOf; //導入依賴的package包/類
@Override
public FloatBuffer slice() {
    byteBuffer.limit(limit * SizeOf.FLOAT);
    byteBuffer.position(position * SizeOf.FLOAT);
    ByteBuffer bb = byteBuffer.slice().order(byteBuffer.order());
    FloatBuffer result = new ByteBufferAsFloatBuffer(bb);
    byteBuffer.clear();
    return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:10,代碼來源:ByteBufferAsFloatBuffer.java

示例10: getChar

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final char getChar() {
  checkNotFreed();
  int newPosition = position + SizeOf.CHAR;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  char result = (char) this.block.peekShort(offset + position, order);
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java

示例11: getDouble

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final double getDouble() {
  checkNotFreed();
  int newPosition = position + SizeOf.DOUBLE;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  double result = Double.longBitsToDouble(this.block.peekLong(offset + position, order));
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java

示例12: getFloat

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final float getFloat() {
  checkNotFreed();
  int newPosition = position + SizeOf.FLOAT;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  float result = Float.intBitsToFloat(this.block.peekInt(offset + position, order));
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java

示例13: getInt

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final int getInt() {
  checkNotFreed();
  int newPosition = position + SizeOf.INT;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  int result = this.block.peekInt(offset + position, order);
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java

示例14: getLong

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final long getLong() {
  checkNotFreed();
  int newPosition = position + SizeOf.LONG;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  long result = this.block.peekLong(offset + position, order);
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java

示例15: getShort

import libcore.io.SizeOf; //導入依賴的package包/類
@Override public final short getShort() {
  checkNotFreed();
  int newPosition = position + SizeOf.SHORT;
  if (newPosition > limit) {
    throw new BufferUnderflowException();
  }
  short result = this.block.peekShort(offset + position, order);
  position = newPosition;
  return result;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:11,代碼來源:DirectByteBuffer.java


注:本文中的libcore.io.SizeOf類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。