Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<Pairing> getPairingsNextRoundSwiss() {
- mPairingsRound = new ArrayList<Pairing>();
- List<Player> tempList = mPlayerList;
- Collections.sort(mPlayerList, new ScoreComparator());// sort highest
- // score
- for (int i = 0; i <= tempList.size() - 1;) {
- if (!tempList.get(i).getPlayerPlayedAgainst(tempList.get(i + 1))) {
- mPairingsRound.add(new Pairing(tempList.get(i), tempList
- .get(i + 1)));
- tempList.remove(i);
- tempList.remove(i + 1);
- } else {
- for (int j = i + 2; j <= tempList.size() - 1; j++) {
- if (!tempList.get(i)
- .getPlayerPlayedAgainst(tempList.get(j))) {
- mPairingsRound.add(new Pairing(tempList.get(i),
- tempList.get(i + 1)));
- tempList.remove(i);
- tempList.remove(i + 1);
- j = tempList.size() + 1;
- }
- }
- }
- }
- return mPairingsRound;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement