public final class XIntSequence extends Object implements XIntIterator
An XIntSequence stores a set of bytes in native memory. Its views
the stored bytes as a sequence of ints and provides methods to read and
modify these values.
To use an instance of this class, the user first needs to initialize the instance by wrapping it around a memory region containing the serialized int sequence. This is done using one of the wrap() or setFrom() methods. Once the instance has been initialized, the user can use the data accessor and modification methods to access and/or modify the the sequence managed by this class.
| Modifier and Type | Method and Description |
|---|---|
static XIntSequence |
create()
Create a new int sequence reader
|
int |
getTo(byte[] val,
int offset)
Copy the serialized int sequence to a byte array object
|
int |
getTo(int[] val,
int offset)
Copy the serialized int sequence to a int array object
|
int |
getTo(long addr,
int offset)
Copy the serialized int sequence to a native memory region
|
int |
getTo(com.neeve.quark.QuarkBuffer val,
int offset)
Copy the serialized int sequence to a
QuarkBuffer |
boolean |
hasNext()
Implementation of
XIntIterator.hasNext() |
boolean |
isInitialized()
Get if the sequence has been initialized or nor
|
boolean |
isOwned()
Get if the sequence was initialized by copying or wrapping
|
XIntIterator |
iterator()
Get an iterator to iterate over a int sequence values
|
int |
next()
Implementation of
XIntIterator.next() |
int |
numElements()
Get the number of elements in a int sequence
|
void |
remove()
Implementation of
XIntIterator.remove() |
XIntSequence |
reset()
Reset a int sequence
|
int |
serializedLength()
Get the serialized length of a int sequence
|
XIntSequence |
setFrom(long addr,
int offset,
int len)
Initialize a sequence by copying a int sequence serialized in a native memory region to a private backing store
|
XIntSequence |
setFrom(com.neeve.quark.QuarkBuffer buffer,
int offset,
int len)
Initialize a sequence by copying a int sequence serialized in a
QuarkBuffer |
XIntSequence |
setFrom(XIntIterator iterator)
Initialize a sequence by copying a int sequence using a
XIntIterator |
XIntSequence |
setFrom(XIntSequence sequence)
Initialize a sequence by copying a int sequence from a
XIntSequence |
XIntIterator |
toFirst()
Implementation of
XIntIterator.toFirst() |
XIntSequence |
wrap(long addr,
int offset,
int len)
Initialize a sequence by wrapping it around a int sequence serialized in a native memory region
|
XIntSequence |
wrap(com.neeve.quark.QuarkBuffer buffer,
int offset,
int len)
Initialize a sequence by wrapping it around a int sequence serialized in a
QuarkBuffer |
public static final XIntSequence create()
public final boolean isInitialized()
public final boolean isOwned()
public XIntIterator toFirst()
XIntIterator.toFirst()toFirst in interface XIntIteratorIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final boolean hasNext()
XIntIterator.hasNext()hasNext in interface XIntIteratorIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int next()
XIntIterator.next()next in interface XIntIteratorIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final void remove()
XIntIterator.remove()remove in interface XIntIteratorpublic final XIntSequence wrap(long addr, int offset, int len)
addr - The address of the memory region containing the serialized int sequenceoffset - The offset from the start of the memory region where the serialized sequence is storedlen - The length of the serialized int sequence
This method initializes a sequence's backing data pointers to a native memory region containing
the serialized int sequence. This method does not make a copy of the serialized sequence.
Therefore, the user must ensure that the source is not modified or freed as long as the sequence
is in active use or reset() is invoked.
This method can be invoked repeatedly with different backing stores. Each invocation resets all internal markers.
This method implictly invokes reset() as part of its processing
public final XIntSequence wrap(com.neeve.quark.QuarkBuffer buffer, int offset, int len)
QuarkBufferbuffer - The buffer containing the serialized int sequenceoffset - The offset into the buffer where the serialized int sequence is storedlen - The length of the serialized int sequence
This method initializes a sequence's backing data pointers to the section of a QuarkBuffer
containing the serialized int sequence. This method does not make a copy of the serialized
sequence. Therefore, the user must ensure that the source is not modified or freed as long as the
sequence is in active use or reset() is invoked.
This method can be invoked repeatedly with different backing stores. Each invocation resets all internal markers.
This method implictly invokes reset() as part of its processing
public final XIntSequence setFrom(long addr, int offset, int len)
addr - The address of the memory region containing the serialized int sequenceoffset - The offset from the start of the memory region where the serialized sequence is storedlen - The length of the serialized int sequence
This method initializes a sequence by copying a int sequence serialized in a native memory region
to a backing store that is private to the sequence object. Once done with using the sequence instance,
the user must invoke reset() to release the resources held by the backing store or release the
sequence object to the garbage collector in which case the backing store resources will be released
when the object is collected by the garbage collector.
This method can be invoked repeatedly with different backing stores. Each invocation invokes
reset() and performs a fresh initialization of the backing store.
public final XIntSequence setFrom(com.neeve.quark.QuarkBuffer buffer, int offset, int len)
QuarkBufferbuffer - The buffer containing the serialized int sequenceoffset - The offset into the buffer where the serialized int sequence is storedlen - The length of the serialized int sequence
This method initializes a sequence by copying a int sequence serialized in a QuarkBuffer
to a backing store that is private to the sequence object. Once done with using the sequence instance,
the user must invoke reset() to release the resources held by the backing store or release the
sequence object to the garbage collector in which case the backing store resources will be released
when the object is collected by the garbage collector.
This method can be invoked repeatedly with different backing stores. Each invocation invokes
reset() and performs a fresh initialization of the backing store.
public final XIntSequence setFrom(XIntSequence sequence)
XIntSequenceiterator - The source sequence
This method initializes a sequence by copying a int sequence from a XIntSequence
to a backing store that is private to the sequence object. Once done with using the sequence instance,
the user must invoke reset() to release the resources held by the backing store or release
the sequence object to the garbage collector in which case the backing store resources will be released
when the object is collected by the garbage collector.
This method can be invoked repeatedly with different backing stores. Each invocation invokes
reset() and performs a fresh initialization of the backing store.
public final XIntSequence setFrom(XIntIterator iterator)
XIntIteratoriterator - The iterator to use to access the sequence
This method initializes a sequence by copying a int sequence using a XIntIterator
to a backing store that is private to the sequence object. Once done with using the sequence instance,
the user must invoke reset() to release the resources held by the backing store or release
the sequence object to the garbage collector in which case the backing store resources will be released
when the object is collected by the garbage collector.
This method can be invoked repeatedly with different backing stores. Each invocation invokes
reset() and performs a fresh initialization of the backing store.
public final int numElements()
IllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int serializedLength()
IllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int getTo(int[] val,
int offset)
val - The destination array object to copy tooffset - The offset into the destination array to copy toIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int getTo(byte[] val,
int offset)
val - The destination array object to copy tooffset - The offset into the destination array to copy toIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int getTo(long addr,
int offset)
addr - The destination memory region to copy tooffset - The offset into memory region to copy toIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final int getTo(com.neeve.quark.QuarkBuffer val,
int offset)
QuarkBufferval - The destination buffer to copy tooffset - The offset into buffer to copy toIllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final XIntIterator iterator()
IllegalStateException - Thrown if the sequence has not been initialized via a wrap() or setFrom methodpublic final XIntSequence reset()
This method resets a int sequence. It releases all resources used by the sequence's private backing store
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.