/** * Returns the value for the specified key. * <ul> * <li> Returns null if the specified key does not exist. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @param key Key for which to return the value * @return Value for the key */ public IntObjectPair get(int key) { if (!_keyToIndexMap.containsKey(key)) { return null; } int index = _keyToIndexMap.get(key); T value = _values.get(index); _reusablePair.setIntValue(index); _reusablePair.setObjectValue(value); return _reusablePair; }
/** * Returns the value for the specified key. * <ul> * <li> Returns null if the specified key does not exist. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @param key Key for which to return the value * @return Value for the key */ public IntDoublePair get(int key) { if (!_keyToIndexMap.containsKey(key)) { return null; } int index = _keyToIndexMap.get(key); double value = _values.getDouble(index); _reusablePair.setIntValue(index); _reusablePair.setDoubleValue(value); return _reusablePair; }
/** * 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 Value of the key */ @SuppressWarnings("unchecked") public void put(int key, T 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); } } }
/** * 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); } } }
@Override public boolean contains(int k) { return containsKey(k); } @Override
public IndexNode getChildNode(int groupUniqueId) { if (positions.containsKey(groupUniqueId)) { return children.get(positions.get(groupUniqueId)); } return null; }
protected void merge(float[] inputs, Int2IntOpenHashMap inputIndex, int node, float[] update, float g, int idx) { int start = inputIndex.get(node); if (!inputIndex.containsKey(node)) { start = inputIndex.size(); inputIndex.put(node, start); } int offset = start * dim; for (int c = 0; c < dim; c++) inputs[offset + c] += g * update[c + idx]; }
protected void merge(float[] inputs, Int2IntOpenHashMap inputIndex, int node, float[] update, float g, int idx) { int start = inputIndex.get(node); if (!inputIndex.containsKey(node)) { start = inputIndex.size(); inputIndex.put(node, start); } int offset = start * dim; for (int c = 0; c < dim; c++) inputs[offset + c] += g * update[c + idx]; }
public CompositeCallback(Collection<KeyCallbackPair<T>> keyCallbackPairs) { slotMap = new Int2IntOpenHashMap(keyCallbackPairs.size()); nextSlot = new int[keyCallbackPairs.size()]; keys = new String[keyCallbackPairs.size()]; callbacks = new Object[keyCallbackPairs.size()]; int i = 0; for (KeyCallbackPair<T> keyCallbackPair : keyCallbackPairs) { String key = keyCallbackPair.getKey(); int hash = hash(key, 0, key.length()); if (slotMap.containsKey(hash)) { nextSlot[i] = slotMap.get(hash); } else { nextSlot[i] = -1; } slotMap.put(hash, i); keys[i] = key; callbacks[i] = keyCallbackPair.getCallback(); i++; } }
if (!super.containsKey(e.getKey())) { innerProduct += defaultValue * e.getValue().intValue(); notBothSparse++;
int last_word = sentences[s][c]; if (last_word == -1) continue; if (!index.containsKey(last_word)) System.out.println("Error"); int offset = index.get(last_word) * dimension * 2; for (c = 0; c < dimension; c++) neu1[c] += layers[c + offset]; if (!index.containsKey(target)) System.out.println("Error"); int l2 = index.get(target) * dimension * 2 + dimension; float f = 0f;