public void loadClasses() { classList.clear(); classHelmet.clear(); classChest.clear(); classLeg.clear(); classBoots.clear(); classEffects.clear(); FileConfiguration c = SettingsManager.getInstance().getClasses(); if (c.contains("classes")) { for (String i : c.getConfigurationSection("classes").getKeys(false)) { String key = ("classes." + i); String name = i.toLowerCase(); ArrayList<ItemStack> inv = getInventory(key); classList.put(name, inv); ItemStack i1 = getHelmet(key); classHelmet.put(name, i1); ItemStack i2 = getChestplate(key); classChest.put(name, i2); ItemStack i3 = getLeggings(key); classLeg.put(name, i3); ItemStack i4 = getBoots(key); classBoots.put(name, i4); ArrayList<PotionEffect> effects = getEffects(key); classEffects.put(name, effects); i = i + 1; } } else { System.out.println("No classes in config!"); } }
public static void clearGates() { lookupBlocks.clear(); lookupNamesNet.clear(); lookupEntrances.clear(); allPortals.clear(); allPortalsNet.clear(); }
public void filter(String compatible, String resolution, String query) { filteredPacks.clear(); int counter = 0; for (int i = 0; i < TexturePack.size(); ++i) { TexturePack texturePack = TexturePack.getTexturePack(i); if (texturePack.isCompatible(ModPack.getSelectedPack().getDir()) && compatibilityCheck(texturePack, compatible) && resolutionCheck(texturePack, resolution) && textSearch(texturePack, query)) { filteredPacks.put(counter, i); counter++; } } for (int i = 0; i < TexturePack.size(); ++i) { TexturePack texturePack = TexturePack.getTexturePack(i); if (!texturePack.isCompatible(ModPack.getSelectedPack().getDir()) && compatibilityCheck(texturePack, compatible) && resolutionCheck(texturePack, resolution) && textSearch(texturePack, query)) { filteredPacks.put(counter, i); counter++; } } if (counter + 1 == TexturePack.size()) { filteredPacks.clear(); fireIntervalRemoved(this, 0, TexturePack.size()); fireIntervalAdded(this, 0, TexturePack.size()); } else { fireIntervalRemoved(this, 0, TexturePack.size()); fireIntervalAdded(this, 0, filteredPacks.size()); } }
private String postprocessTopology(PrintWriter out, String oldString) throws Exception { // initialize nodeMapForTopology.clear(); messageLinkMapForTopology.clear(); StringWriter stringOut = new StringWriter(); // transform string to document DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream oldResultInputStream = new ByteArrayInputStream(oldString.getBytes()); Document oldDocument = builder.parse(oldResultInputStream); // rearrange document Document newDocument = handleTopologyDocument(oldDocument); // transform document to string TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(newDocument); StreamResult result = new StreamResult(stringOut); transformer.transform(source, result); stringOut.flush(); return stringOut.toString(); }
synchronized void populate(List<ObaStop> stops, List<ObaRoute> routes) { int count = 0; if (mStopMarkers.size() >= FUZZY_MAX_MARKER_COUNT) { // We've exceed our max, so clear the current marker cache and start over Log.d(TAG, "Exceed max marker cache of " + FUZZY_MAX_MARKER_COUNT + ", clearing cache"); removeMarkersFromMap(); mStopMarkers.clear(); mStops.clear(); // Make sure the currently focused stop still exists on the map if (mCurrentFocusStop != null && mFocusedRoutes != null) { addMarkerToMap(mCurrentFocusStop, mFocusedRoutes); count++; } } for (ObaStop stop : stops) { if (!mStopMarkers.containsKey(stop.getId())) { addMarkerToMap(stop, routes); count++; } } Log.d(TAG, "Added " + count + " markers, total markers = " + mStopMarkers.size()); }
// - Set keys public static void setKeys(ArrayList<LanguageKey> keys) { keyById.clear(); keyById.clear(); keyByKey.clear(); for (LanguageKey key : keys) addKey(key); }
private void pruningHGHelper(HyperGraph hg) { this.bestLogProb = getLogNormalizationConstant(); // set the best_log_prob numSurvivedEdges = 0; numSurvivedNodes = 0; processedNodesTbl.clear(); pruningNode(hg.goalNode); // clear up processedNodesTbl.clear(); System.out.println( "Item suvived ratio: " + numSurvivedNodes * 1.0 / hg.numNodes + " = " + numSurvivedNodes + "/" + hg.numNodes); System.out.println( "Deduct suvived ratio: " + numSurvivedEdges * 1.0 / hg.numEdges + " = " + numSurvivedEdges + "/" + hg.numEdges); }
/** Time Complexity: L[0].length() * S compared to S * L Think why use this way */ public ArrayList<Integer> findSubstring(String S, String[] L) { HashMap<String, Integer> need = new HashMap<String, Integer>(); HashMap<String, Integer> has = new HashMap<String, Integer>(); ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 0; i < L.length; i++) { need.put(L[i], need.containsKey(L[i]) ? need.get(L[i]) + 1 : 1); } int k = L[0].length(); for (int i = 0; i < k; i++) { has.clear(); int start = i; for (int end = start; end <= S.length() - k; end += k) { String cur = S.substring(end, end + k); if (need.containsKey(cur)) { // NOTE while (has.get(cur) == need.get( cur)) { // NOTE compare with MimimumWindowSubstring, we need get all results, so // we need to compare end_cursor in has and need String temp = S.substring(start, start + k); has.put(temp, has.get(temp) - 1); start += k; } has.put(cur, has.containsKey(cur) ? has.get(cur) + 1 : 1); if ((end - start + k) == L.length * k) { // NOTE ans.add(start); } } else { has.clear(); start = end + k; } } } return ans; }
@FXML protected void clear_tab(ActionEvent ae) { group.getChildren().clear(); wrap_pane.getChildren().clear(); label_box.getChildren().clear(); wrap_pane = new HBox(); label_box = new VBox(); group.getChildren().add(wrap_pane); group.getChildren().add(label_box); mDataLabelToRow.clear(); mRefLabelToRow.clear(); mDataTables.clear(); mRefDataTables.clear(); mNextLabelIndex = 0; mNextRefLabelIndex = 0; mNextRun = 1; mLabelTable = null; mRefLabelTable = null; first = true; }
public void filterPacks() { packPanels.clear(); packs.removeAll(); currentPacks.clear(); packMapping.clear(); int counter = 0; selectedPack = 0; packInfo.setText(""); // all removed, repaint packs.repaint(); // not really needed // modPacksAdded = false; for (ModPack pack : ModPack.getPackArray()) { if (filterForTab(pack) && mcVersionCheck(pack) && avaliabilityCheck(pack) && textSearch(pack)) { currentPacks.put(counter, pack); packMapping.put(counter, pack.getIndex()); addPack(pack); counter++; } } updateDatas(); updatePacks(); }
public synchronized void cleanClassmodel() { // helps to keep alive even if some error appeared elsewhere leads to memory leak!!! if (createdPackages != null) { final Iterator packages = createdPackages.values().iterator(); while (packages.hasNext()) { final BinPackage pack = (BinPackage) packages.next(); pack.cleanUpForRebuild(); } } createdPackages.clear(); for (int i = 0, max = compilationUnits.size(); i < max; i++) { final CompilationUnit source = (CompilationUnit) compilationUnits.get(i); source.getSource().invalidateCaches(); } SourceMap.invalidateSourceCaches(); compilationUnits.clear(); nonJavaUnits.clear(); definedTypeNames.clear(); loadedTypes.clear(); javaLangPackage = createPackageForName("java.lang"); defaultPackage = createPackageForName(""); objectRef = null; arrayInterfaces = null; getProjectLoader().projectCleanup(); }
/** * Reset the random object to initial state (only useful if the random object is seeded) However * can be specified to leave the PUID counters alone. * * @param clear_count specify if we want to clear the UUID values. */ public static synchronized void reset(final boolean clear_count) { RANDOMS.clear(); SPECIFIC_RANDOMS.clear(); if (clear_count) { COUNTERS.clear(); } }
private void locateViews() { mCellsPos.clear(); mCells.clear(); int count_y = mCellsCountY; int count_x = mCellsCountX; for (int j = 0; j < count_y; j++) { for (int i = 0; i < count_x; i++) { View child = getViewFromAdapter(i, j); // int type = getViewTypeFromAdapter(calcIndex2(i, j)); if (child == null) continue; mCells.put(calcIndex2(i, j), child); mCellsPos.put(child, calcIndex2(i, j)); } } if (mCellsWidth == null || mCellsWidth.length != mCellsCountX) { mCellsWidth = new int[mCellsCountX]; } if (mCellsHeight == null || mCellsHeight.length != mCellsCountY) { mCellsHeight = new int[mCellsCountY]; } Arrays.fill(mCellsWidth, 0); Arrays.fill(mCellsHeight, 0); }
/** * C++ callback function. * * <p>Notifies the event listener that a game has started. */ public void gameStarted() { try { // get the players self = null; allies.clear(); allyIDs.clear(); enemies.clear(); enemyIDs.clear(); players.clear(); int[] playerData = getPlayersData(); for (int index = 0; index < playerData.length; index += Player.numAttributes) { String name = new String(getPlayerName(playerData[index])); Player player = new Player(playerData, index, name); players.put(player.getID(), player); if (player.isSelf()) { self = player; } else if (player.isAlly()) { allies.add(player); allyIDs.add(player.getID()); } else if (player.isEnemy()) { enemies.add(player); enemyIDs.add(player.getID()); } else if (player.isNeutral()) { neutralPlayer = player; } } // get unit data units.clear(); playerUnits.clear(); alliedUnits.clear(); enemyUnits.clear(); neutralUnits.clear(); int[] unitData = getAllUnitsData(); for (int index = 0; index < unitData.length; index += Unit.numAttributes) { int id = unitData[index]; Unit unit = new Unit(id); unit.update(unitData, index); units.put(id, unit); if (self != null && unit.getPlayerID() == self.getID()) { playerUnits.add(unit); } else if (allyIDs.contains(unit.getPlayerID())) { alliedUnits.add(unit); } else if (enemyIDs.contains(unit.getPlayerID())) { enemyUnits.add(unit); } else { neutralUnits.add(unit); } } listener.gameStarted(); } catch (Error e) { e.printStackTrace(); } }
// - Set languages public static void setLanguages(ArrayList<Language> languageList) { languageList.clear(); languageById.clear(); languageByCode.clear(); for (Language language : languageList) addLanguage(language); }
private void parseIntent() { Intent intent = getIntent(); receiveUserAdds = intent.getStringArrayExtra(RECEIVE_ADDRESS); HashMap<Long, String> tmpUserMap = (HashMap<Long, String>) intent.getSerializableExtra(RECEIVE_SELECTUSERCIRCLE_NAME); HashMap<String, String> tmpPhoneEmailMap = (HashMap<String, String>) intent.getSerializableExtra(RECEIVE_SELECTPHONEEMAIL_NAME); if (tmpUserMap != null) { mSelectedUserCircleNameMap.clear(); mSelectedUserCircleNameMap.putAll(tmpUserMap); } if (tmpPhoneEmailMap != null) { mSelectedPhoneEmailNameMap.clear(); mSelectedPhoneEmailNameMap.putAll(tmpPhoneEmailMap); } mInviteId = intent.getLongExtra(CircleUtils.CIRCLE_ID, -1); if (mInviteId > 0) { overrideRightTextActionBtn(R.string.qiupu_invite, inviteClickListener); } else { overrideRightTextActionBtn(R.string.label_ok, pickClickListener); } if (intent.getIntExtra(PICK_FROM, -1) == PICK_FROM_COMPOSE) { setHeadTitle(R.string.string_select_user); } else { setHeadTitle(R.string.invite_people_title); } }
public String addRequest(RequestVO request) throws SeeWorldException { String senderId = request.getSender_id(); String recieverId = request.getReciever_id(); if (senderId.equals(recieverId)) { return SELF; } params.clear(); params.put(IRequestDAO.RECEIVER, recieverId); params.put(IRequestDAO.SENDER, senderId); if (requestDao.getCount(params) > 0) { return S_REQUEST; } params.clear(); params.put(IRequestDAO.SENDER, recieverId); params.put(IRequestDAO.RECEIVER, senderId); if (requestDao.getCount(params) > 0) { return R_REQUEST; } if (friendLogic.areFriends(new FriendVO(recieverId, senderId))) { return FRIEND; } Request instance = new Request(); User reciever = userDao.findById(recieverId); User sender = userDao.findById(senderId); instance.setSender(sender); instance.setReciever(reciever); requestDao.save(instance); RequestVO requestVo = new RequestVO(instance); requestJson = JSONObject.fromObject(requestVo); return SUCCESS; }
public boolean setMapsPosition() { ballPosition.clear(); canBallMove.clear(); boolean canMove = false; for (Map.Entry<Point, Integer> entry : balls.entrySet()) { Point key = entry.getKey(); int value = entry.getValue(); ballPosition.put( key, new Point(gridPoints[key.x][key.y].centerX(), gridPoints[key.x][key.y].centerY())); if (canMove(key)) { canBallMove.put(key, true); canMove = true; } else { canBallMove.put(key, false); } newPoints.put(key, value); } return canMove; }
/* * Initialise Method * @params start and goal coordinates */ public void init(int sX, int sY, int gX, int gY) { cellHash.clear(); path.clear(); openHash.clear(); while (!openList.isEmpty()) openList.poll(); k_m = 0; s_start.x = sX; s_start.y = sY; s_goal.x = gX; s_goal.y = gY; CellInfo tmp = new CellInfo(); tmp.g = 0; tmp.rhs = 0; tmp.cost = C1; cellHash.put(s_goal, tmp); tmp = new CellInfo(); tmp.g = tmp.rhs = heuristic(s_start, s_goal); tmp.cost = C1; cellHash.put(s_start, tmp); s_start = calculateKey(s_start); s_last = s_start; }
public static void resetTextures() { for (Texture texture : textures.values()) { texture.release(); } cacheTextureFiles.clear(); textures.clear(); ZanMinimap.instance.texman.reset(); }
@Override public void reset() { shortContainer.clear(); byteContainer.clear(); intContainer.clear(); floatContainer.clear(); doubleContainer.clear(); }
/** * Empties this style group set. The style sheet is listener is not removed, use {@link * #release()} to do that. */ public void clear() { byEdgeIdGroups.clear(); byNodeIdGroups.clear(); bySpriteIdGroups.clear(); byGraphIdGroups.clear(); groups.clear(); zIndex.clear(); shadow.clear(); }
// - Remove language public static void clearLanguages() { languageById.clear(); languageByCode.clear(); languageList.clear(); keyById.clear(); keyByKey.clear(); keyList.clear(); }
private void resetProcessor() { itemsetsSupport.clear(); rulesMeasures.clear(); items.clear(); itemsets.clear(); rules.clear(); itemCounter = 0; itemsetCounter = 0; }
/** * * Go over all the records, collecting metadata keys and records' type field offset in the * Parcel. These are stored in mKeyToPosMap for latter retrieval. Format of a metadata record: * * <pre> * 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | record size | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | metadata key | // TITLE * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | metadata type | // STRING_VAL * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | .... metadata payload .... | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * </pre> * * @param parcel With the serialized records. * @param bytesLeft How many bytes in the parcel should be processed. * @return false if an error occurred during parsing. */ private boolean scanAllRecords(Parcel parcel, int bytesLeft) { int recCount = 0; boolean error = false; mKeyToPosMap.clear(); while (bytesLeft > kRecordHeaderSize) { final int start = parcel.dataPosition(); // Check the size. final int size = parcel.readInt(); if (size <= kRecordHeaderSize) { // at least 1 byte should be present. Log.e(TAG, "Record is too short"); error = true; break; } // Check the metadata key. final int metadataId = parcel.readInt(); if (!checkMetadataId(metadataId)) { error = true; break; } // Store the record offset which points to the type // field so we can later on read/unmarshall the record // payload. if (mKeyToPosMap.containsKey(metadataId)) { Log.e(TAG, "Duplicate metadata ID found"); error = true; break; } mKeyToPosMap.put(metadataId, parcel.dataPosition()); // Check the metadata type. final int metadataType = parcel.readInt(); if (metadataType <= 0 || metadataType > LAST_TYPE) { Log.e(TAG, "Invalid metadata type " + metadataType); error = true; break; } // Skip to the next one. parcel.setDataPosition(start + size); bytesLeft -= size; ++recCount; } if (0 != bytesLeft || error) { Log.e(TAG, "Ran out of data or error on record " + recCount); mKeyToPosMap.clear(); return false; } else { return true; } }
/** * Resets all profession data for the player. This clears all professions the player has, leaving * no remaining data until the player professes again to a starting class. */ public void resetAll() { ArrayList<String> keys = new ArrayList<String>(classes.keySet()); for (String key : keys) { reset(key); } skills.clear(); binds.clear(); attributes.clear(); attribPoints = 0; }
public static void createEnchantments(String[] data) { CommandGenerator.log("Creating Enchantments..."); enchantments.clear(); enchantmentIDs.clear(); for (String a : data) { String[] values = a.split(","); new EnchantmentType(Integer.parseInt(values[0]), values[1], Integer.parseInt(values[2])); } CommandGenerator.log("Successfully created " + enchantments.size() + " enchantments."); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void testNodeProcessingSchema(LastMatchMap oper) { CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink(); oper.last.setSink(matchSink); oper.setKey("a"); oper.setValue(3); oper.setTypeEQ(); oper.beginWindow(0); HashMap<String, Number> input = new HashMap<String, Number>(); input.put("a", 4); input.put("b", 20); input.put("c", 1000); oper.data.process(input); input.put("a", 3); input.put("b", 20); input.put("c", 1000); oper.data.process(input); input.clear(); input.put("a", 2); oper.data.process(input); input.clear(); input.put("a", 4); input.put("b", 21); input.put("c", 1000); oper.data.process(input); input.clear(); input.put("a", 3); input.put("b", 52); input.put("c", 5); oper.data.process(input); oper.endWindow(); Assert.assertEquals("number emitted tuples", 1, matchSink.count); HashMap<String, Number> tuple = (HashMap<String, Number>) matchSink.tuple; Number aval = tuple.get("a"); Number bval = tuple.get("b"); Assert.assertEquals("Value of a was ", 3, aval.intValue()); Assert.assertEquals("Value of a was ", 52, bval.intValue()); matchSink.clear(); oper.beginWindow(0); input.clear(); input.put("a", 2); input.put("b", 20); input.put("c", 1000); oper.data.process(input); input.clear(); input.put("a", 5); oper.data.process(input); oper.endWindow(); // There should be no emit as all tuples do not match Assert.assertEquals("number emitted tuples", 0, matchSink.count); matchSink.clear(); }
@Override public void run() { PreparedStatement ps = null; String updates; String wheres; StringBuilder sbu = new StringBuilder(); StringBuilder sbw = new StringBuilder(); for (Map.Entry<String, Object> entry : data.entrySet()) { sbu.append(entry.getKey()).append(" = ?,"); } for (Map.Entry<String, Object> entry : where.entrySet()) { sbw.append(entry.getKey()).append(" = "); if (entry.getValue().getClass().equals(String.class) || entry.getValue().getClass().equals(UUID.class)) { sbw.append("'").append(entry.getValue()).append("' AND "); } else { sbw.append(entry.getValue()).append(" AND "); } } where.clear(); updates = sbu.toString().substring(0, sbu.length() - 1); wheres = sbw.toString().substring(0, sbw.length() - 5); String query = "UPDATE " + table + " SET " + updates + " WHERE " + wheres; try { service.testConnection(connection); ps = connection.prepareStatement(query); int s = 1; for (Map.Entry<String, Object> entry : data.entrySet()) { if (entry.getValue().getClass().equals(String.class) || entry.getValue().getClass().equals(UUID.class)) { ps.setString(s, entry.getValue().toString()); } if (entry.getValue() instanceof Integer) { ps.setInt(s, (Integer) entry.getValue()); } if (entry.getValue() instanceof Long) { ps.setLong(s, (Long) entry.getValue()); } s++; } data.clear(); ps.executeUpdate(); } catch (SQLException e) { plugin.debug("Update error for " + table + "! " + e.getMessage()); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { plugin.debug("Error closing " + table + "! " + e.getMessage()); } } }
public static void cleanup() { loadHash = 0; loadDate = 0; allStickers.clear(); stickerSets.clear(); stickersByEmoji.clear(); stickerSetsById.clear(); stickerSetsByName.clear(); loadingStickers = false; stickersLoaded = false; }