@Override public synchronized boolean add(QueueObject to) { if (to == null) return false; playerSize += to.getNumPlayers(); teamSize += to.getTeams().size(); return super.add(to); }
public synchronized Collection<ArenaTeam> getTeams() { List<ArenaTeam> teams = new ArrayList<ArenaTeam>(); for (QueueObject team : this) { teams.addAll(team.getTeams()); } return teams; }
public synchronized Collection<ArenaPlayer> getArenaPlayers() { List<ArenaPlayer> players = new ArrayList<ArenaPlayer>(); for (QueueObject qo : this) { for (ArenaTeam t : qo.getTeams()) { players.addAll(t.getPlayers()); } } return players; }
@Override public boolean remove(QueueObject queueObject) { if (super.remove(queueObject)) { playerSize -= queueObject.getNumPlayers(); teamSize -= queueObject.getTeams().size(); return true; } return false; }
public synchronized ArenaTeam remove(ArenaTeam team) { Iterator<QueueObject> iter = this.iterator(); while (iter.hasNext()) { QueueObject qo = iter.next(); if (qo.hasTeam(team)) { iter.remove(); playerSize -= qo.getNumPlayers(); teamSize -= qo.getTeams().size(); return team; } } return null; }
public synchronized ArenaTeam remove(ArenaPlayer p) { Iterator<QueueObject> iter = this.iterator(); while (iter.hasNext()) { QueueObject qo = iter.next(); if (qo.hasMember(p)) { iter.remove(); playerSize--; teamSize -= qo.getTeams().size(); return qo.getTeam(p); } } return null; }