diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java b/src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java index 26ab968a..7b97b268 100644 --- a/src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java +++ b/src/de/lmu/ifi/dbs/elki/data/SparseNumberVector.java @@ -34,6 +34,35 @@ import gnu.trove.map.TIntDoubleMap; */ public interface SparseNumberVector<N extends Number> extends NumberVector<N>, SparseFeatureVector<N> { /** + * Iterator over non-zero features only, <em>ascendingly</em>. + * + * Note: depending on the underlying implementation, this may or may not be + * the dimension. Use {@link #iterDim} to get the actual dimension. In fact, + * usually this will be the ith non-zero value, assuming an array + * representation. + * + * Think of this number as an iterator. For efficiency, it has a primitive + * type! + * + * Intended usage: + * + * <pre> + * {@code + * for (int iter = v.iter(); v.iterValid(iter); iter = v.iterAdvance(iter)) { + * final int dim = v.iterDim(iter); + * final double val = v.iterDoubleValue(iter); + * // Do something. + * } + * } + * </pre> + * + * @return Identifier for the first non-zero dimension, <b>not necessarily the + * dimension!</b> + */ + @Override + int iter(); + + /** * Update the vector space dimensionality. * * @param maxdim New dimensionality @@ -41,6 +70,102 @@ public interface SparseNumberVector<N extends Number> extends NumberVector<N>, S void setDimensionality(int maxdim); /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + double iterDoubleValue(int iter); + + /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + float iterFloatValue(int iter); + + /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + int iterIntValue(int iter); + + /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + short iterShortValue(int iter); + + /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + long iterLongValue(int iter); + + /** + * Get the value of the iterators' current dimension. + * + * @param iter Iterator + * @return Value at the current position + */ + byte iterByteValue(int iter); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterDoubleValue}. + */ + @Override + @Deprecated + double doubleValue(int dimension); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterFloatValue}. + */ + @Override + @Deprecated + float floatValue(int dimension); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterIntValue}. + */ + @Override + @Deprecated + int intValue(int dimension); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterLongValue}. + */ + @Override + @Deprecated + long longValue(int dimension); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterShortValue}. + */ + @Override + @Deprecated + short shortValue(int dimension); + + /** + * @deprecated As the vectors are sparse, try to iterate over the sparse + * dimensions only, see {@link #iterByteValue}. + */ + @Override + @Deprecated + byte byteValue(int dimension); + + /** * Factory for sparse number vectors: make from a dim-value map. * * @author Erich Schubert |