public final class VectorEntry extends Object implements Cloneable
An entry in a sparse vector. This represents the key-value pair at one entry in a sparse vector, similar to Map.Entry
does for maps.
The entry class does not support a public setValue method; to set the value at an entry on a mutable sparse vector, use MutableSparseVector.set(VectorEntry, double)
. This design allows the same VectorEntry to work for both Mutable and Immutable vectors, since the Immutable vectors can safely return the VectorEntry knowing it cannot change the (immutable) values, while the set operation on Mutable vectors allows the element to be changed.
Modifier and Type | Class and Description |
---|---|
static class |
VectorEntry.State
The state of an entry in a sparse vector.
|
Modifier and Type | Method and Description |
---|---|
VectorEntry |
clone() |
long |
getKey()
Get the key at this entry.
|
double |
getValue()
Get the value at this entry.
|
SparseVector |
getVector()
Get the sparse vector associated with this entry.
|
boolean |
isSet()
Query whether this entry is set.
|
String |
toString() |
public long getKey()
Get the key at this entry.
public double getValue()
Get the value at this entry.
public boolean isSet()
Query whether this entry is set.
true
if the entry’s key is in the key set; false
if it is only in the key domain.@Nullable public SparseVector getVector()
Get the sparse vector associated with this entry. An entry does not necessarily have a reference to a vector.
null
if no vector is linked.public VectorEntry clone()