public DoubleColumn set(int i, double val) { data.set(i, val); return this; }
/** * Helper method that performs all operations required to swap two values. * <ul> * <li> Swaps the values in the array that backs the heap. </li> * <li> Updates the indexToKey and keyToIndex maps due to the swap. </li> * </ul> * @param index1 Index to swap * @param index2 Index to swap */ private void swapValues(int index1, int index2) { if (index1 == index2) { return; } double tmp = _values.getDouble(index1); _values.set(index1, _values.getDouble(index2)); _values.set(index2, tmp); swapKeys(index1, index2); }
/** * Puts the element into the priority queue. * <ul> * <li> If key does not exist, it is added to the priority queue. </li> * <li> If key exists, then the value is updated, and the priority queue ordering is maintained. </li> * <li> Runtime complexity of {@code O(log(n)}). </li> * </ul> * @param key Integer key for the value * @param value Double value of the key */ public void put(int key, double value) { if (!_keyToIndexMap.containsKey(key)) { _values.add(value); int last = _values.size() - 1; updateKeyIndexMap(key, last); siftUp(last); } else { int index = _keyToIndexMap.get(key); _values.set(index, value); // Sift the value up or down, as the case may be. if (!siftDown(index)) { siftUp(index); } } }
/** * Set the given value to the entry with the index specified. * * @param i the entry * @param value the value to set to the entry */ public void set(int i, double value) { entries.set(i, value); }
public DoubleColumn set(int i, double val) { data.set(i, val); return this; }
public void set(int r, double value) { data.set(r, value); }
@Override public void set(double k) { if (last == -1) throw new IllegalStateException(); DoubleArrayList.this.set(last, k); } @Override
scores.set(slot, score);
counts.add(1); } else { sums.set(idx, sums.getDouble(idx) + r.getValue()); counts.set(idx, counts.getInt(idx) + 1);
/** * Add the vector specified. This is a vector addition that does an * element-by-element addition. * * @param other the vector to add. */ public void add(DoubleDenseVector other) { if (isSingleton) { throw new RuntimeException("Cannot add to singleton vector"); } if (other.isSingleton) { ensureCapacity(other.singletonIndex + 1); entries.set(other.singletonIndex, entries.getDouble(other.singletonIndex) + other.singletonValue); } else { ensureCapacity(other.entries.size()); for (int i = 0; i < other.entries.size(); ++i) { entries.set(i, entries.getDouble(i) + other.entries.getDouble(i)); } } }
@Override public void setValue(DoubleWritable value) { // Update the value object from the superclass. getValue().set(value.get()); // Update the value stored in the backing array. edgeValues.set(index, value.get()); } }
/** * Remove edge at position i. * * @param i Position of edge to be removed */ private void removeAt(int i) { // The order of the edges is irrelevant, so we can simply replace // the deleted edge with the rightmost element, thus achieving constant // time. if (i == neighbors.size() - 1) { neighbors.popLong(); edgeValues.popDouble(); } else { neighbors.set(i, neighbors.popLong()); edgeValues.set(i, edgeValues.popDouble()); } // If needed after the removal, trim the arrays. trimBack(); }
scores.set(slot, score);
counts.add(1); } else { sums.set(idx, sums.getDouble(idx) + r.getValue()); counts.set(idx, counts.getInt(idx) + 1);