java.lang.Object
org.kink_lang.kink.HostResultCore
org.kink_lang.kink.Val
org.kink_lang.kink.BinVal
- All Implemented Interfaces:
Comparable<BinVal>,HostResult,Just<BinVal>,OpResult<BinVal>
A
bin val, which represents an immutable array of bytes.
A bin val holds Java byte arrays as a binary tree in order to avoid allocation of the entire array on concatenation. The byte array is substantiated on demand.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a read-onlyByteBufferof the content of this bin.byte[]bytes()Returns the copied bytes of the bin.intReturns a negative number ifthisis less thanarg, 0 ifthisis equivalent toarg, or a positive number ifthisis greater thanarg.Returns a bin value which concatenatesthisandtail.voidcopyToBytes(int from, int to, byte[] bytes, int at) Copy the range of this bin intobytesat theatindex.booleanReturns true if and only ifargis a bin val and has the same vm and the equivalent bytes withthis.byteget(int ind) Returns the byte at the ind.inthashCode()booleanisEmpty()Returns whether the bin value has no byte.just()Returns the result of the operation.intsize()Returns the size of the bin.slice(int from, int to) Returns a sliced bin betweenfrom(inclusive) andto(exclusive).toString()Methods inherited from class org.kink_lang.kink.Val
getVar, getVarSymHandleSet, hasVar, makeHostResultCore, setVarMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.kink_lang.kink.op.Just
justOrNull
-
Method Details
-
just
Description copied from interface:JustReturns the result of the operation. -
size
public int size()Returns the size of the bin.- Returns:
- the size of the bin.
-
isEmpty
public boolean isEmpty()Returns whether the bin value has no byte.- Returns:
- whether the bin value has no byte.
-
bytes
public byte[] bytes()Returns the copied bytes of the bin.- Returns:
- the copied bytes of the bin.
-
copyToBytes
public void copyToBytes(int from, int to, byte[] bytes, int at) Copy the range of this bin intobytesat theatindex.- Parameters:
from- the inclusive start index.to- the exclusive end index.bytes- the destination bytes.at- the start index of the destination bytes.
-
get
public byte get(int ind) Returns the byte at the ind.- Parameters:
ind- the index of the byte.- Returns:
- the byte at the ind.
- Throws:
IndexOutOfBoundsException- ifindis out of the range of the bin.
-
byteBuffer
Returns a read-onlyByteBufferof the content of this bin.The capacity of the result ByteBuffer is the size of the bin. The limit of the result ByteBuffer is set to the size of the bin. The position of the result ByteBuffer is set to 0.
- Returns:
- a read-only
ByteBufferof the content of this bin.
-
slice
Returns a sliced bin betweenfrom(inclusive) andto(exclusive).- Parameters:
from- the inclusive index where the result is sliced from.to- the exclusive index where the result is sliced to.- Returns:
- a sliced bin.
- Throws:
IndexOutOfBoundsException- iffromortoare out of the range of the bin.IllegalArgumentException- iffromis larger thanto.
-
compareTo
Returns a negative number ifthisis less thanarg, 0 ifthisis equivalent toarg, or a positive number ifthisis greater thanarg.Comparison is done for the bytes of
thisandarg, treating the bytes as unsigned numbers.Comparison is agnostic with
vmfield.- Specified by:
compareToin interfaceComparable<BinVal>- Parameters:
arg- the arg bin to compare with.- Returns:
- the comparison number.
-
concat
Returns a bin value which concatenatesthisandtail. OpError on overflow.- Parameters:
back- the bin which is appended to the result.- Returns:
- a bin value which concatenates
thisandback.
-
equals
Returns true if and only ifargis a bin val and has the same vm and the equivalent bytes withthis. -
hashCode
public int hashCode() -
toString
-