<commit_before>/*
 * LensKit, an open source recommender systems toolkit.
 * Copyright 2010-2012 Regents of the University of Minnesota and contributors
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package org.grouplens.lenskit.vectors;

import javax.annotation.Nullable;

/**
 * @author <NAME>
 */
public final class VectorEntry {
    @Nullable
    final SparseVector vector;
    private int index;
    private long key;
    private double value;

    VectorEntry(@Nullable SparseVector vec, int i, long k, double val) {
        vector = vec;
        index = i;
        key = k;
        value = val;
    }

    public VectorEntry(long k, double v) {
        this(null, -1, k, v);
    }

    public long getKey() {
        return key;
    }

    public double getValue() {
        return value;
    }

    int getIndex() {
        return index;
    }

    void set(int i, long k, double v) {
        index = i;
        key = k;
        value = v;
    }

    void set(long k, double v) {
        key = k;
        value = v;
    }

    void setValue(double v) {
        value = v;
    }
}<commit_msg>Add VectorEntry docs (closes #187)<commit_after>/*
 * LensKit, an open source recommender systems toolkit.
 * Copyright 2010-2012 Regents of the University of Minnesota and contributors
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package org.grouplens.lenskit.vectors;

import javax.annotation.Nullable;

/**
 * An entry in a vector. This represents the key-value pair at one entry
 * in a vector, similar to {@link java.util.Map.Entry} does for maps.
 * <p>
 * The entry class does not support a public setValue method; to set the
 * value at an entry on a mutable sparse vector, use
 * {@link MutableSparseVector#set(VectorEntry, double)}.
 *
 * @author <NAME>
 */
public final class VectorEntry {
    @Nullable
    final SparseVector vector;
    private int index;
    private long key;
    private double value;

    /**
     * Construct a new vector entry for a particular vector.
     * @param vec The vector this entry is from.
     * @param i The index in the vector of this entry.
     * @param k The entry's key.
     * @param val The entry's value.
     */
    VectorEntry(@Nullable SparseVector vec, int i, long k, double val) {
        vector = vec;
        index = i;
        key = k;
        value = val;
    }

    /**
     * Construct a new vector entry.
     * @param k The entry's key.
     * @param v The entry's value.
     */
    public VectorEntry(long k, double v) {
        this(null, -1, k, v);
    }

    /**
     * Get the key at this entry.
     * @return The key of this entry.
     */
    public long getKey() {
        return key;
    }

    /**
     * Get the value at this entry.
     * @return The value of this entry.
     */
    public double getValue() {
        return value;
    }

    /**
     * Internal method to get associated index, if specified.
     * @return The index into the vector of this entry.
     */
    int getIndex() {
        return index;
    }

    /**
     * Update the entry (used for fast iteration).
     * @param i The new index.
     * @param k The new key.
     * @param v the new value.
     */
    void set(int i, long k, double v) {
        index = i;
        key = k;
        value = v;
    }

    /**
     * Update the entry (used for fast iteration).
     * @param k The new key.
     * @param v The new value.
     */
    void set(long k, double v) {
        key = k;
        value = v;
    }

    /**
     * Update the value. Used only to implement {@link MutableSparseVector#set(VectorEntry, double)}.
     * @param v The new value
     */
    void setValue(double v) {
        value = v;
    }
}
{'fraction_non_alphanumeric': 0.08577654516640254, 'fraction_numerical': 0.009310618066561015, 'mean_word_length': 2.3304749340369395, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374648', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1402, 'n_words': 645}