/** * <a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent * of the following code: * <pre> * if (!map.containsKey(key)) map.put(value); * </pre> * * @param key The key of the value to check. * @param value The value to put if <code>key</code> does not exist. * @return <code>true</code> if <code>key</code> did not exist and <code>value</code> * was placed in the map. */ public boolean putIfAbsent(int key, int value) { int keyIndex = indexOf(key); if (!indexExists(keyIndex)) { indexInsert(keyIndex, key, value); return true; } else { return false; } }
/** * If <code>key</code> exists, <code>putValue</code> is inserted into the map, * otherwise any existing value is incremented by <code>additionValue</code>. * * @param key * The key of the value to adjust. * @param putValue * The value to put if <code>key</code> does not exist. * @param incrementValue * The value to add to the existing value if <code>key</code> exists. * @return Returns the current value associated with <code>key</code> (after * changes). */ @Override public int putOrAdd(int key, int putValue, int incrementValue) { assert assigned < mask + 1; int keyIndex = indexOf(key); if (indexExists(keyIndex)) { putValue = ((int) (( values[keyIndex]) + (incrementValue))); indexReplace(keyIndex, putValue); } else { indexInsert(keyIndex, key, putValue); } return putValue; }
public int visitNode(int node) { int index = visitedNodes.indexOf(node); if (index >= 0) { return visitedNodes.indexGet(index); } int fromHere = 0; for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (fsa.isArcFinal(arc)) fromHere++; if (!fsa.isArcTerminal(arc)) { fromHere += visitNode(fsa.getEndNode(arc)); } } visitedNodes.put(node, fromHere); return fromHere; } }
public int visitNode(int node) { int index = visitedNodes.indexOf(node); if (index >= 0) { return visitedNodes.indexGet(index); } int fromHere = 0; for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (fsa.isArcFinal(arc)) fromHere++; if (!fsa.isArcTerminal(arc)) { fromHere += visitNode(fsa.getEndNode(arc)); } } visitedNodes.put(node, fromHere); return fromHere; } }
final int index = stemToRowIndex.indexOf(stemIndex); if (stemToRowIndex.indexExists(index))