|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.data.vector.bytevector.DenseByteVector
public class DenseByteVector
A vector of fixed length holding byte counts at specific positions. Only
positive values of counts are supported. Each index can store a number
between 0 and 255 (both inclusive). Attempts to store negative numbers or
numbers larger than 255 cause an exception.
The maximum length is 2147483645.
The implementation is not thread-safe.
Constructor Summary | |
---|---|
DenseByteVector(byte[] counts)
Creates a new vector initialized by the passed counts. |
|
DenseByteVector(DenseByteVector byteVector)
Creates a new vector initialized by the passed vector. |
|
DenseByteVector(int length)
Creates a new instance with the specified length. |
Method Summary | |
---|---|
DenseByteVector |
add(DenseByteVector bv,
boolean remainder)
Returns a new vector with the sum of the counts at each position. |
int |
cardinality()
Returns the number of counts larger than zero stored in this vector. |
void |
clear(int index)
Sets the count at the specified index to zero. |
void |
clear(int startIdx,
int endIdx)
Resets the count at all positions from startIdx (inclusive) to endIdx (exclusive). |
DenseByteVector |
concatenate(DenseByteVector bv)
Appends the argument at the end of this vector. |
boolean |
equals(Object obj)
|
void |
fill(int startIdx,
int endIdx,
int count)
Sets the new count value at all positions from startIdx (inclusive) to endIdx (exclusive). |
int |
get(int index)
Returns the count stored at the specified position. |
int[] |
getAllCounts()
Returns a copy of the internal array of counts. |
byte[] |
getAllCountsAsBytes()
Returns a copy of the internal array of counts. |
int |
hashCode()
|
boolean |
isEmpty()
Checks all counts and returns true if they are all zero. |
int |
length()
Returns the length of the vector. |
DenseByteVector |
max(DenseByteVector bv)
Returns a new vector with the maximum of the counts at each position. |
DenseByteVector |
min(DenseByteVector bv)
Returns a new vector with the minimum of the counts at each position. |
int |
nextCountIndex(int idx)
Returns the index equal to or larger than the specified index that contains a count larger than zero. |
int |
nextZeroIndex(int idx)
Returns the index equal to or larger than the specified index that contains a zero count. |
void |
set(int index,
int count)
Sets the new count value at the specified index. |
DenseByteVector |
subSequence(int startIdx,
int endIdx)
Creates and returns a new byte vector that contains a subsequence of this vector, beginning with the byte at index startIdx and with
its last byte being this' byte at position endIdx - 1 . |
long |
sumOfAllCounts()
Calculates the checksum, the sum of all counts stored. |
String |
toString()
Creates a string containing all counts of this vector (in braces ({ }) and comma separated), starting (on the left) with index 0. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
DenseByteVector(int length)
length
- the fixed length of the vector.DenseByteVector(byte[] counts)
counts
- the value to initialize the new vector with.DenseByteVector(DenseByteVector byteVector)
byteVector
- the byte vector to clone.Method Detail |
---|
public int length()
public void set(int index, int count)
index
- the index of the count value to change.count
- the new value for the specified position.
ArrayIndexOutOfBoundsException
- if the index is negative or larger
than or equal to the length of the vector.
IllegalArgumentException
- if the count is negative or larger than
255public void fill(int startIdx, int endIdx, int count)
startIdx
- the first index to store the new value at.endIdx
- the first index the new value should not be stored anymore.count
- the new value that should be stored in the specified index
range
ArrayIndexOutOfBoundsException
- if startIdx is negative or endIdx
is larger than the length of the vector.
IllegalArgumentException
- if the endIdx is smaller than the
startIdx, or if the specified count is negative or larger
than 255.public void clear(int index)
set(int, int)
with count zero.
index
- the index of the position the count should be reset at.
ArrayIndexOutOfBoundsException
- if the index is negative or larger
than or equal to the length of the vector.public void clear(int startIdx, int endIdx)
fill(int, int, int)
with
count zero.
startIdx
- the first index to set the count to zero.endIdx
- the first index the count not be reset anymore.
ArrayIndexOutOfBoundsException
- if startIdx is negative or endIdx
is larger than the length of the vector.
IllegalArgumentException
- if the endIdx is smaller than the
startIdx.public int get(int index)
index
- the index of the count to return
ArrayIndexOutOfBoundsException
- if the specified index is negative
or too large.public int nextCountIndex(int idx)
idx
on) -1 is returned.
I.e. if a value not equal -1 is returned, a call to get(int)
with the result as argument returns a number larger than zero.
idx
- the starting index to look for the next count larger than
zero. It is okay to pass an index larger than the length of
this vector (in which case -1 is returned).
idx
, or -1 if the vector contains
only zeros on and after idx
.public int nextZeroIndex(int idx)
idx
on) -1 is returned. I.e. if
a value not equal -1 is returned, a call to get(int)
with the
result as argument returns zero.
idx
- the starting index to look for the next zero count. It is okay
to pass an index larger than the length of this vector (in
which case -1 is returned).
idx
, or -1 if the vector contains only counts
larger than zero on and after idx
.public DenseByteVector add(DenseByteVector bv, boolean remainder)
bv
- the vector to add to this one (position-wise).remainder
- if true and the result of the addition is larger than
255, the value in the result vector will be set to the
remainder when divided by 255 - if false, the result vector is
set to 255 if the sum is larger than 255. (Setting it to true
performs slightly better.)
public DenseByteVector max(DenseByteVector bv)
bv
- the vector to compute the maximum of (position-wise).
public DenseByteVector min(DenseByteVector bv)
bv
- the vector to compute the minimum of (position-wise).
public DenseByteVector concatenate(DenseByteVector bv)
bv
- the vector to concatenate with this.
public DenseByteVector subSequence(int startIdx, int endIdx)
startIdx
and with
its last byte being this' byte at position endIdx - 1
.
The length of the result vector is endIdx - startIdx
. If
startIdx
equals endIdx
a vector of length
zero is returned.
startIdx
- the startIdx of the subsequenceendIdx
- the first byte in this vector after startIdx that is not
included in the result sequence.
endIdx - startIdx
containing the subsequence of this vector from
startIdx
(included) to endIdx
(not
included anymore).public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
public byte[] getAllCountsAsBytes()
getAllCounts()
, which returns an int
array only holding positive values from 0 ... 255.
public int[] getAllCounts()
public long sumOfAllCounts()
public int cardinality()
public boolean isEmpty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |