-
Notifications
You must be signed in to change notification settings - Fork 1
Java Crystal methods reference
Jacob edited this page Aug 24, 2016
·
1 revision
Below is a table of Java ByteBuffer methods and their Crystal counterparts. Methods written like read(Int32)
mean that the argument is the class' name itself, not an instance of it.
Java | Crystal | notes |
---|---|---|
allocate(int capacity) |
new(capacity : Int) |
|
wrap(byte[] array) |
new(slice : Slice(UInt8)) |
|
array() |
to_slice |
|
compact() |
compact |
|
rewind() |
rewind |
|
clear() |
clear |
|
reset() |
reset |
|
mark() |
mark |
|
position() |
position |
|
position(int newPosition) |
position=(index : Int) |
|
limit() |
limit |
|
limit(int newLimit) |
limit=(index : Int) |
|
capacity() |
capacity , bytesize , size
|
bytesize == capacity == size is always true for ByteBuffer but not for other buffers. |
duplicate() |
dup |
#clone is also available which is like #dup but doesn't share memory with the original. |
get() |
read , read(Int8) , read(UInt8)
|
#read is the same as #read(UInt8) . |
get(int index) |
read(index : Int) , read(index : Int, Int8) , read(index : Int, UInt8)
|
#read(index : Int) is the same as #read(index : Int, UInt8) . |
getShort() |
read(Int16) , read(UInt16)
|
|
getShort(int index) |
read(index : Int, Int16) , read(index : Int, UInt16)
|
|
getInt() |
read(Int32) , read(UInt32)
|
|
getInt(int index) |
read(index : Int, Int32) , read(index : Int, UInt32)
|
|
getLong() |
read(Int64) , read(UInt64)
|
|
getLong(int index) |
read(index : Int, Int64) , read(index : Int, UInt64)
|
|
getFloat() |
read(Float32) |
|
getFloat(int index) |
read(index : Int, Float32) |
|
getDouble() |
read(Float64) |
|
getDouble(int index) |
read(index : Int, Float64) |
|
get(byte[] dst) |
read(slice : Slice(UInt8)) |
|
put(byte b) |
write(value : Int8) , write(value : UInt8)
|
|
put(int index, byte b) |
write(index : Int, value : Int8) , write(index : Int, value : UInt8)
|
|
putShort(short value) |
write(value : Int16) , write(value : UInt16)
|
|
putShort(int index, short value) |
write(index : Int, value : Int16) , write(index : Int, value : UInt16)
|
|
putInt(int value) |
write(value : Int32) , write(value : UInt32)
|
|
putInt(int index, int value) |
write(index : Int, value : Int32) , write(index : Int, value : UInt32)
|
|
putLong(long value) |
write(value : Int64) , write(value : UInt64)
|
|
putLong(int index, long value) |
write(index : Int, value : Int64) , write(index : Int, value : UInt64)
|
|
putFloat(float value) |
write(value : Float32) |
|
putFloat(int index, float value) |
write(index : Int, value : Float32) |
|
putDouble(double value) |
write(value : Float64) |
|
putDouble(int index, double value) |
write(index : Int, value : Float64) |
|
put(ByteBuffer src) |
write_bytes(object) |
object can be any type that implements #to_io . |
order() |
order |
|
order(ByteOrder bo) |
order=(order : IO::ByteFormat) |
Possible values are IO::ByteFormat::BigEndian , IO::ByteFormat::LittleEndian , IO::ByteFormat::NetworkEndian and IO::ByteFormat::SystemEndian . |
asShortBuffer() |
as_int16_buffer , as_uint16_buffer
|
|
asIntBuffer() |
as_int32_buffer , as_uint32_buffer
|
|
asLongBuffer() |
as_int64_buffer , as_uint64_buffer
|
|
asFloatBuffer() |
as_float32_buffer |
|
asDoubleBuffer() |
as_float64_buffer |