org.grouplens.lenskit.vectors

## Class VectorEntry

• All Implemented Interfaces:
Cloneable

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.

Since:
0.11
Compatibility
Public
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  VectorEntry.State
The state of an entry in a sparse vector.
• ### Method Summary

All Methods
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()
• ### Methods inherited from class java.lang.Object

equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### Method Detail

• #### getKey

public long getKey()

Get the key at this entry.

Returns:
The key of this entry.
• #### getValue

public double getValue()

Get the value at this entry.

Returns:
The value of this entry.
• #### isSet

public boolean isSet()

Query whether this entry is set.

Returns:
true if the entry’s key is in the key set; false if it is only in the key domain.
• #### getVector

@Nullable
public SparseVector getVector()

Get the sparse vector associated with this entry. An entry does not necessarily have a reference to a vector.

Returns:
The associated vector, or null if no vector is linked.
• #### clone

public VectorEntry clone()
Overrides:
clone in class Object
• #### toString

public String toString()
Overrides:
toString in class Object
Skip navigation links