private int getShortestDistanceByTable( LinkedList<DiscoveredVertex> fwd, LinkedList<DiscoveredVertex> bwd, DistanceTable dt) { int d = Integer.MAX_VALUE; DiscoveredVertex u, v; u = v = null; for (DiscoveredVertex s : fwd) { for (DiscoveredVertex t : bwd) { int d_st = dt.get(s.vertex.getId(), t.vertex.getId()); int d_ = d_st + s.key.distance + t.key.distance; if (d_st == Integer.MAX_VALUE) { continue; } if (d_ < d) { u = s; v = t; d = d_; } } } fwd.clear(); bwd.clear(); if (u != null) { fwd.add(u); bwd.add(v); } return d; }
/** * Notification that its safe to update the node now with any operations that could potentially * effect the node's bounds. * * @param src The node or Node Component that is to be updated. */ public void updateNodeBoundsChanges(Object src) { Node kid; int size = (removedChildren == null) ? 0 : removedChildren.size(); for (int i = 0; i < size; i++) { kid = (Node) removedChildren.get(i); implGroup.removeChild(kid); } size = (addedChildren == null) ? 0 : addedChildren.size(); for (int i = 0; i < size; i++) { kid = (Node) addedChildren.get(i); implGroup.addChild(kid); } addedChildren.clear(); removedChildren.clear(); if (maskChanged) { implGroup.setMask(vfVisible); maskChanged = false; } }
@Test(timeout = 5 * 60 * 1000) public void testJNIMemoryManagerHeapExpansion() { LinkedList<RefCountedTester> heldRefs = new LinkedList<RefCountedTester>(); JNIMemoryManager mgr = JNIMemoryManager.getMgr(); mgr.flush(); mgr.setMinimumReferencesToCache(1024); int maxItems = 10000; // 10000 should cause several heap expansions to occur for (int i = 0; i < maxItems; i++) { heldRefs.add(RefCountedTester.make()); } assertEquals("didn't pin as many as it should", maxItems, mgr.getNumPinnedObjects()); // now release them. heldRefs.clear(); while (mgr.getNumPinnedObjects() != 0) { MemoryTestHelper.forceJavaHeapWeakReferenceClear(); // Do a collection mgr.gc(true); } assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects()); // this should cause the heap to shrink, and then grow for (int i = 0; i < maxItems / 2; i++) { heldRefs.add(RefCountedTester.make()); } assertEquals("didn't pin as many as it should", maxItems / 2, mgr.getNumPinnedObjects()); // now release them. heldRefs.clear(); // and force a collection while (mgr.getNumPinnedObjects() != 0) { MemoryTestHelper.forceJavaHeapWeakReferenceClear(); // Do a collection mgr.gc(true); } assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects()); }
/** Resets the back and forward list, and also disable the back and forward buttons. */ private void resetHistory() { // clear the back and forward list backList.clear(); forwardList.clear(); backButton.setEnabled(false); forwardButton.setEnabled(false); }
/** * Redistributes the net reactions based on the current core and edge reaction models. Especially * useful when one or more species has been moved from the edge to the core since the last * pressure-dependent calculation. * * @param cerm The current core/edge reaction model */ public void updateReactionLists(CoreEdgeReactionModel cerm) throws PDepException { // Merge the net reaction and nonincluded reactinon lists together // We will recalculate how to distribute them LinkedList<PDepReaction> reactionList = new LinkedList<PDepReaction>(); for (int i = 0; i < netReactionList.size(); i++) { PDepReaction rxn = netReactionList.get(i); reactionList.add(rxn); } for (int i = 0; i < nonincludedReactionList.size(); i++) { PDepReaction rxn = nonincludedReactionList.get(i); reactionList.add(rxn); } netReactionList.clear(); nonincludedReactionList.clear(); for (int i = 0; i < reactionList.size(); i++) { PDepReaction forward = reactionList.get(i); PDepReaction reverse = (PDepReaction) forward.getReverseReaction(); if (forward == null) throw new PDepException( "Encountered null forward reaction while updating PDepNetwork reaction lists."); else if (reverse == null) throw new PDepException( "Encountered null reverse reaction while updating PDepNetwork reaction lists."); if (forward.isCoreReaction(cerm) || reverse.isCoreReaction(cerm)) netReactionList.add(forward); else if (forward.getReactant().getIncluded() && forward.getProduct().getIncluded()) netReactionList.add(forward); else nonincludedReactionList.add(forward); } }
@Override public void reset(int size) { // reset allocations/frees count first, as it's not used // for any functionality but to show information metrics.reset(); // --- used try { usedLock.writeLock().lock(); used.clear(); usedMemorySize.set(0); } finally { usedLock.writeLock().unlock(); } metrics.mark("vmtable.usedSize", usedMemorySize.longValue()); metrics.mark("vmtable.usedBlocksCount", used.size()); // --- free try { freeLock.writeLock().lock(); free.clear(); free.add(new TableBlock(0, size)); freeMemorySize.set(size); } finally { freeLock.writeLock().unlock(); } metrics.mark("vmtable.freeSize", freeMemorySize.longValue()); metrics.mark("vmtable.freeBlocksCount", free.size()); }
/** * Attempts to execute a command and adds it to the undo stack if the command executes * successfully. * * @param command The command to execute. */ void executeCommand(Command command) { boolean success = command.execDo(); // Only mess with the command stacks if the command was executed // successfully. if (success) { // If the command invalidates the command stacks then // clear the command stacks. if (command.invalidates()) { undoStack.clear(); redoStack.clear(); } // If the command is undoable, it must be added to the undo // stack and the redo stack must be cleared. if (command.isUndoable()) { undoStack.addLast(command); if (undoStack.size() > mThreshold) { undoStack.removeFirst(); } redoStack.clear(); } // Necessary so that the undo/redo menu gets an update // AFTER the command has successfully executed. publisher.publishEvent(new Event()); } }
@Override protected void onResume() { super.onResume(); mSerialDevice = UsbSerialProber.acquire(mUsbManager); Debug.d(TAG, "Resumed, mSerialDevice=" + mSerialDevice); if (mSerialDevice == null) { Debug.i(TAG, "No serial device."); mTextViewCmbsConnectedAns.setText(R.string.no); mTextViewHanConnectedDeviceAns.setText(R.string.not_available); mHanDeviceLinkedList.clear(); updateHanDeviceTable(); updateLedStatus(); } else { try { mSerialDevice.open(); mTextViewCmbsConnectedAns.setText(R.string.yes); } catch (IOException e) { Debug.e(TAG, "Error setting up device: " + e.getMessage()); mTextViewCmbsConnectedAns.setText(R.string.no); mTextViewHanConnectedDeviceAns.setText(R.string.not_available); mHanDeviceLinkedList.clear(); updateHanDeviceTable(); updateLedStatus(); try { mSerialDevice.close(); } catch (IOException e2) { // Ignore. } mSerialDevice = null; return; } Debug.d(TAG, "Serial device: " + mSerialDevice); } onDeviceStateChange(); }
private LinkedList<Vector2f> calc(Field2D field, Vector2f start, Vector2f goal, boolean flag) { if (start.equals(goal)) { LinkedList<Vector2f> v = new LinkedList<Vector2f>(); v.add(start); return v; } this.goal = goal; if (visitedCache == null) { visitedCache = new HashSet<Vector2f>(); } else { visitedCache.clear(); } if (pathes == null) { pathes = new LinkedList<ScoredPath>(); } else { pathes.clear(); } visitedCache.add(start); if (path == null) { path = new LinkedList<Vector2f>(); } else { path.clear(); } path.add(start); if (spath == null) { spath = new ScoredPath(0, path); } else { spath.score = 0; spath.path = path; } pathes.add(spath); return astar(field, flag); }
public static void visit(final IFb2Node root, final IFb2NodeVisitor visitor) { final LinkedList<IFb2Node> nodes = new LinkedList<IFb2Node>(); nodes.add(root); try { for (IFb2Node node = getFirst(nodes); node != null; node = getFirst(nodes)) { switch (visitor.handle(node)) { case Stop: return; case ProcessOnlyChildren: nodes.clear(); case Continue: if (node instanceof IFb2CompositeNode) { nodes.addAll(0, ((IFb2CompositeNode) node).getChildren()); } break; case NextSibling: break; } } } catch (final Throwable th) { th.printStackTrace(); } finally { nodes.clear(); } }
/** * Compute the and aggregate using a temporary uncompressed bitmap. * * <p>This function does not seek to match the "sizeinbits" attributes of the input bitmaps. * * @param container where the aggregate is written * @param bufSize buffer size used during the computation in 64-bit words (per input bitmap) * @param bitmaps the source bitmaps */ public static void bufferedandWithContainer( final BitmapStorage32 container, final int bufSize, final EWAHCompressedBitmap32... bitmaps) { java.util.LinkedList<IteratingBufferedRunningLengthWord32> al = new java.util.LinkedList<IteratingBufferedRunningLengthWord32>(); for (EWAHCompressedBitmap32 bitmap : bitmaps) { al.add(new IteratingBufferedRunningLengthWord32(bitmap)); } int[] hardbitmap = new int[bufSize * bitmaps.length]; for (IteratingRLW32 i : al) if (i.size() == 0) { al.clear(); break; } while (!al.isEmpty()) { Arrays.fill(hardbitmap, ~0); int effective = Integer.MAX_VALUE; for (IteratingRLW32 i : al) { int eff = IteratorAggregation32.inplaceand(hardbitmap, i); if (eff < effective) effective = eff; } for (int k = 0; k < effective; ++k) container.addWord(hardbitmap[k]); for (IteratingRLW32 i : al) if (i.size() == 0) { al.clear(); break; } } }
/** * Removes all data items from the series and, unless the series is already empty, sends a {@link * SeriesChangeEvent} to all registered listeners. Clears down and resets all the local calculated * fields. */ public void clear() { super.clear(); sumFullKRValues = 0.0; sumFullDValues = 0.0; yyValues.clear(); fullKRValues.clear(); fullDValues.clear(); }
@Override public void onBackKeyPressed() { SharedPreferences.Editor editor = recordPref.edit(); editor.putInt("RECORD", record); editor.apply(); SceneManager.getInstance().loadMenuScene(engine); birdArray.clear(); plumageArray.clear(); }
@Override protected void onActivityResult(int arg1, int arg0, Intent arg2) { super.onActivityResult(arg1, arg0, arg2); if (arg1 == REQUEST_CODE && arg0 == RESULT_OK) { if (mList != null) { mList.clear(); } mImageUri = arg2.getData(); if (mImageUri != null) { String path = getImagePath(mImageUri); mList.add(path); imageLoader.displayImage( mList.get(0).replace("/mnt", "file:/"), user_manager_user_head, options); } } else if (arg1 == REQUEST_CODE1 && arg0 == Activity.RESULT_OK) { if (mList != null) { mList.clear(); } if (file != null && file.exists()) { mList.add(file.getPath()); imageLoader.displayImage( mList.get(0).replace("/mnt", "file:/"), user_manager_user_head, options); } } if (arg0 == MyConstants.REQUEST_NICKNAME) { nicknameTextView.setText(arg2.getExtras().getString("nickname")); } if (arg0 == MyConstants.REQUEST_PASSWORD) { if (arg2.getExtras().getString("password") != null) { user_manager_alter_passwd_stub.setText(arg2.getExtras().getString("password")); pwchange = true; } } if (arg0 == MyConstants.REQUEST_NAME) { user_manager_tv_name.setText(arg2.getExtras().getString("name")); } if (arg0 == MyConstants.REQUEST_PHONENUB) { user_manager_tv_phonnumber.setText(arg2.getExtras().getString("phonenub")); } if (arg0 == MyConstants.REQUEST_EMAIL) { user_manager_tv_qq.setText(arg2.getExtras().getString("email")); } if (arg0 == MyConstants.REQUEST_ADDRESS) { user_manager_tv_address.setText(arg2.getExtras().getString("address")); } if (arg0 == MyConstants.REQUEST_NET) { user_manager_tv_net.setText(arg2.getExtras().getString("net")); } if (arg0 == MyConstants.REQUEST_COMPANY) { user_manager_tv_company.setText(arg2.getExtras().getString("company")); } }
public void sendAllInfo() { sendStartingArmiesInfo(player1); sendStartingArmiesInfo(player2); sendUpdateMapInfo(player1); sendUpdateMapInfo(player2); sendOpponentMovesInfo(player1); opponentMovesPlayer1.clear(); sendOpponentMovesInfo(player2); opponentMovesPlayer2.clear(); }
/** @see java.io.ObjectOutputStream#reset() */ @Override public void reset() throws IOException { root = null; checked.clear(); fieldDescription = null; simpleName = null; traceStack.clear(); nameStack.clear(); writeObjectMethodMissing.clear(); }
private void closeStatements() throws SQLException { // Note: Some JDBC drivers like Informix require resultSet.close() // before statement.close() although the second one is supposed to // close open ResultSets by itself according to the API doc. for (ResultSet resultSet : resultSets) { resultSet.close(); } for (Statement statement : statements) { statement.close(); } resultSets.clear(); statements.clear(); }
/** * Creates an empty pressure-dependent network. Does not automatically add the network to the * PDepNetwork.networks collection. */ public PDepNetwork() { isomerList = new LinkedList<PDepIsomer>(); isomerList.clear(); pathReactionList = new LinkedList<PDepReaction>(); pathReactionList.clear(); netReactionList = new LinkedList<PDepReaction>(); netReactionList.clear(); nonincludedReactionList = new LinkedList<PDepReaction>(); nonincludedReactionList.clear(); altered = false; id = networkCount + 1; networkCount++; }
/** Called when the auction finishes */ public void onStop() { synchronized (syncObj) { for (int i = 0; i < asks.size(); i++) { super.match((MessageAsk) asks.get(i), null, 0); } for (int i = 0; i < bids.size(); i++) { super.match(null, (MessageBid) bids.get(i), 0); } asks.clear(); bids.clear(); } }
public void restart() { activity.runOnUpdateThread( new Runnable() { @Override public void run() { detachChildren(); activity.setCurrentScene(new GameoverScene()); } }); enemiesToBeAdded.clear(); enemies.clear(); }
public synchronized void clear() { Object[] keys = map.keySet().toArray(); for (Object key : keys) { remove(key); } // Now, reset all containers. map.clear(); lastAccessedList.clear(); ageList.clear(); cacheHits = 0; cacheMisses = 0; }
/** * Removes all data items from the series and, unless the series is already empty, sends a {@link * SeriesChangeEvent} to all registered listeners. Clears down and resets all the local calculated * fields. */ public void clear() { super.clear(); fastSum = 0.0; fastMultiplyer = Double.MAX_VALUE; fastYYValues.clear(); slowSum = 0.0; slowMultiplyer = Double.MAX_VALUE; slowYYValues.clear(); signalSmoothingSum = 0.0; signalSmoothingMultiplyer = Double.MAX_VALUE; signalSmoothingYYValues.clear(); prevFastEMA = 0; prevSlowEMA = 0; prevSignalSmoothingEMA = 0; }
/** Resets the game's variables to their default states and starts a new game. */ private void resetGame() { /* * Reset the score statistics. (Note that nextFruitPoints is reset in * the spawnFruit function later on). */ this.score = 0; this.fruitsEaten = 0; /* * Reset both the new game and game over flags. */ this.isNewGame = false; this.isGameOver = false; /* * Create the head at the center of the board. */ Point head = new Point(BoardPanel.COL_COUNT / 2, BoardPanel.ROW_COUNT / 2); /* * Clear the snake list and add the head. */ snake.clear(); snake.add(head); /* * Clear the board and add the head. */ board.clearBoard(); board.setTile(head, TileType.SnakeHead); /* * Clear the directions and add north as the * default direction. */ directions.clear(); directions.add(Direction.North); /* * Reset the logic timer. */ logicTimer.reset(); /* * Spawn a new fruit. */ spawnFruit(); }
@Override protected void onRestoreInstanceState(Bundle inState) { float[] data = inState.getFloatArray("Pressure"); if (data != null) { pressureHistory.clear(); for (float f : data) { pressureHistory.add((double) f); } } data = inState.getFloatArray("Pressure Smoothing Window"); if (data != null) { pressureSmoothingWin.clear(); for (float f : data) { pressureSmoothingWin.push((double) f); } } data = inState.getFloatArray("Altitude"); if (data != null) { altitudeHistory.clear(); for (float f : data) { altitudeHistory.add((double) f); } } data = inState.getFloatArray("Altitude Smoothing Window"); if (data != null) { altitudeSmoothingWin.clear(); for (float f : data) { altitudeSmoothingWin.push((double) f); } } data = inState.getFloatArray("Temperature"); if (data != null) { tempHistory.clear(); for (float f : data) { tempHistory.add((double) f); } } data = inState.getFloatArray("Temperature Smoothing Window"); if (data != null) { tempSmoothingWin.clear(); for (float f : data) { tempSmoothingWin.push((double) f); } } plotLongHistory(); }
/** * Convert the items in the list to a JsonUtil array of JsonUtil objects, and remove these objects * from the list. Currently only String fields are supported. * * @param list The list as the source of objects to be converted to JsonUtil array. * @param cnt The number of objects to be converted, and deleted from the list. e.g. cnt = 10 * means list[0] to list[9] will be converted and deleted. */ public static String linkedList2Json(ConcurrentLinkedQueue list, int cnt) { StringBuilder sb = new StringBuilder(); // List sub = list..subList(0, cnt); LinkedList sub = new LinkedList(); for (int i = 0; i < cnt; i++) sub.add(list.poll()); Field[] fields = null; Class cls = null; // create a json array sb.append("{\"objects\":["); boolean firstObject = true; for (Object obj : sub) { if (firstObject) { sb.append("{"); firstObject = false; } else { sb.append(", {"); } if (fields == null) { fields = obj.getClass().getFields(); cls = obj.getClass(); } // do sth to retrieve each field value -> json property of json object // add to json array for (int i = 0; i < fields.length; i++) { Field f = fields[i]; jsonFromField(sb, obj, i, f); } sb.append("}"); } sb.append("]}"); sub.clear(); return sb.toString(); }
public void actionPerformed(ActionEvent event) { int i; JButton aux = (JButton) event.getSource(); if (aux == closeCompra) { try { String[] information = { JOptionPane.showInputDialog(null, "nombre"), JOptionPane.showInputDialog(null, "numero de targeta") }; ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()); oos.writeObject(information); oos.flush(); oos.writeObject(products); oos.flush(); oos.writeObject(comprados); oos.flush(); cleanTable(); comprados.clear(); } catch (Exception e) { System.out.print("\nerror al cerrar la compra " + e.getMessage()); } return; } for (i = 0; aux != mostrador.addCar[i]; i++) {; } if (products.get(i).getPiesas() > 0) { products.get(i).popParts(); addCompra(products.get(i)); total.setText("total: " + comprados.getLast().getTotal()); } else { JOptionPane.showMessageDialog(null, "no seas menso ya no hay mas piesas! :@"); } }
static void endDependencyLoading() { dependenciesLoading--; if (dependenciesLoading == 0 && !callbacks.isEmpty()) { for (Command cmd : callbacks) { cmd.execute(); } callbacks.clear(); } else if (dependenciesLoading == 0 && !ConnectorBundleLoader.get() .isBundleLoaded(ConnectorBundleLoader.DEFERRED_BUNDLE_NAME)) { ConnectorBundleLoader.get() .loadBundle( ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, new BundleLoadCallback() { @Override public void loaded() { // Nothing to do } @Override public void failed(Throwable reason) { VConsole.error(reason); } }); } }
public void destroyTemplate() { template = null; sections.clear(); sections = null; modifiers.clear(); modifiers = null; }
/** * 根据参数showArea 和 showBlock 跟显示的数据内容 * * @param showArea * @param showBlock */ public void updateShowText(String showArea, String showBlock) { if (showArea == null || showBlock == null) { return; } for (int i = 0; i < groups.size(); i++) { if (groups.get(i).equals(showArea)) { // 如果showArea的值和ArrayList中的某个值相等时,将earaListViewAdapter的选中位置设置在第i个位置 earaListViewAdapter.setSelectedPosition(i); childrenItem.clear(); // 立即将这个链表清掉,准备把位置腾出来给children链表的第i个位置的LinkedList // children为SparseArray(LinkedList<String>) if (i < children.size()) { // children为SparseArray(LinkedList<String>) childrenItem.addAll(children.get(i)); } tEaraPosition = i; // 将地域的位置现在修改为之前选中的第i个位置 break; } } for (int j = 0; j < childrenItem.size(); j++) { if (childrenItem.get(j).replace("不限", "").equals(showBlock.trim())) { plateListViewAdapter.setSelectedPosition(j); // 商圈的适配器设置到选中的位置 tBlockPosition = j; break; } } setDefaultSelect(); }
protected final int a(int paramInt, Object... paramVarArgs) { if (paramInt == 0) { paramVarArgs = (a.a.a.c.a) paramVarArgs[0]; paramVarArgs.ci(1, jsT); paramVarArgs.ci(2, fUi); paramVarArgs.d(3, 8, jFB); return 0; } if (paramInt == 1) { return a.a.a.a.cg(1, jsT) + 0 + a.a.a.a.cg(2, fUi) + a.a.a.a.c(3, 8, jFB); } if (paramInt == 2) { paramVarArgs = (byte[]) paramVarArgs[0]; jFB.clear(); paramVarArgs = new a.a.a.a.a(paramVarArgs, iTR); for (paramInt = com.tencent.mm.at.a.a(paramVarArgs); paramInt > 0; paramInt = com.tencent.mm.at.a.a(paramVarArgs)) { if (!super.a(paramVarArgs, this, paramInt)) { paramVarArgs.bog(); } } return 0; } if (paramInt == 3) { Object localObject1 = (a.a.a.a.a) paramVarArgs[0]; ajc localajc = (ajc) paramVarArgs[1]; paramInt = ((Integer) paramVarArgs[2]).intValue(); switch (paramInt) { default: return -1; case 1: jsT = maU.jC(); return 0; case 2: fUi = maU.jC(); return 0; } paramVarArgs = ((a.a.a.a.a) localObject1).sJ(paramInt); int i = paramVarArgs.size(); paramInt = 0; while (paramInt < i) { Object localObject2 = (byte[]) paramVarArgs.get(paramInt); localObject1 = new ajb(); localObject2 = new a.a.a.a.a((byte[]) localObject2, iTR); for (boolean bool = true; bool; bool = ((ajb) localObject1) .a( (a.a.a.a.a) localObject2, (com.tencent.mm.at.a) localObject1, com.tencent.mm.at.a.a((a.a.a.a.a) localObject2))) {} jFB.add(localObject1); paramInt += 1; } return 0; } return -1; }