Java Code Examples for javolution.util.FastMap#newInstance()

The following examples show how to use javolution.util.FastMap#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MySQL5PlayerVarsDAO.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Map<String, Object> load(final int playerId) {
	final Map<String, Object> map = FastMap.newInstance();
	DB.select("SELECT param,value FROM player_vars WHERE player_id=?", new ParamReadStH() {

		@Override
		public void handleRead(ResultSet rset) throws SQLException {
			while (rset.next()) {
				String key = rset.getString("param");
				String value = rset.getString("value");
				map.put(key, value);
			}
		}

		@Override
		public void setParams(PreparedStatement st) throws SQLException {
			st.setInt(1, playerId);
		}
	});

	return map;
}
 
Example 2
Source File: NpcShoutData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void afterUnmarshal(Unmarshaller u, Object parent) {
	for (ShoutGroup group : shoutGroups) {
		for (int i = group.getShoutNpcs().size() - 1; i >= 0; i--) {
			ShoutList shoutList = group.getShoutNpcs().get(i);
			int worldId = shoutList.getRestrictWorld();

			FastMap<Integer, List<NpcShout>> worldShouts = shoutsByWorldNpcs.get(worldId);
			if (worldShouts == null) {
				worldShouts = FastMap.newInstance();
				this.shoutsByWorldNpcs.put(worldId, worldShouts);
			}

			this.count += shoutList.getNpcShouts().size();
			for (int j = shoutList.getNpcIds().size() - 1; j >= 0; j--) {
				int npcId = shoutList.getNpcIds().get(j);
				List<NpcShout> shouts = new ArrayList<NpcShout>(shoutList.getNpcShouts());
				if (worldShouts.get(npcId) == null) {
					worldShouts.put(npcId, shouts);
				}
				else {
					worldShouts.get(npcId).addAll(shouts);
				}
				shoutList.getNpcIds().remove(j);
			}
			shoutList.getNpcShouts().clear();
			shoutList.makeNull();
			group.getShoutNpcs().remove(i);
		}
		group.makeNull();
	}
	this.shoutGroups.clear();
	this.shoutGroups = null;
}
 
Example 3
Source File: MySQL5PlayerDAO.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Set<Integer> getInactiveAccounts(final int daysOfInactivity, final int limitation) {
	String SELECT_QUERY = "SELECT account_id FROM players WHERE UNIX_TIMESTAMP(CURDATE())-UNIX_TIMESTAMP(last_online) > ? * 24 * 60 * 60";

	final Map<Integer, Integer> inactiveAccounts = FastMap.newInstance();

	DB.select(SELECT_QUERY, new ParamReadStH() {

		@Override
		public void setParams(PreparedStatement stmt) throws SQLException {
			stmt.setInt(1, daysOfInactivity);
		}

		@Override
		public void handleRead(ResultSet rset) throws SQLException {
			while (rset.next() && (limitation == 0 || limitation > inactiveAccounts.size())) {
				int accountId = rset.getInt("account_id");
				// number of inactive chars on account
				Integer numberOfChars = 0;

				if ((numberOfChars = inactiveAccounts.get(accountId)) != null) {
					inactiveAccounts.put(accountId, numberOfChars + 1);
				}
				else {
					inactiveAccounts.put(accountId, 1);
				}
			}
		}
	});

	// filter accounts with active chars on them
	for (Iterator<Entry<Integer, Integer>> i = inactiveAccounts.entrySet().iterator(); i.hasNext();) {
		Entry<Integer, Integer> entry = i.next();

		// atleast one active char on account
		if (entry.getValue() < this.getCharacterCountOnAccount(entry.getKey())) {
			i.remove();
		}
	}

	return inactiveAccounts.keySet();
}
 
Example 4
Source File: HouseRegistry.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public HouseRegistry(House owner) {
	this.owner = owner;
	this.objects = FastMap.newInstance();
	this.customParts = FastMap.newInstance();
}
 
Example 5
Source File: ItemStorage.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public ItemStorage(StorageType storageType) {
	this.limit = storageType.getLimit();
	this.specialLimit = storageType.getSpecialLimit();
	this.storageType = storageType;
	this.items = FastMap.newInstance();
}
 
Example 6
Source File: SurveyService.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public SurveyService() {
	activeItems = FastMap.newInstance();
	this.htmlTemplate = HTMLCache.getInstance().getHTML("surveyTemplate.xhtml");
	ThreadPoolManager.getInstance().scheduleAtFixedRate(new TaskUpdate(), 2000, SecurityConfig.SURVEY_DELAY * 60000);
}
 
Example 7
Source File: SeenCreatureList.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public boolean add(Creature creature) {
	if (seenCreatures == null) {
		seenCreatures = FastMap.newInstance();
	}
	return seenCreatures.putIfAbsent(creature.getObjectId(), creature) == null;
}