Advertisement
cc2k

Untitled

Aug 22nd, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public List<Pairing> getPairingsNextRoundSwiss() {
  2. mPairingsRound = new ArrayList<Pairing>();
  3. List<Player> tempList = mPlayerList;
  4. Collections.sort(mPlayerList, new ScoreComparator());// sort highest
  5. // score
  6.  
  7. for (int i = 0; i <= tempList.size() - 1;) {
  8.  
  9. if (!tempList.get(i).getPlayerPlayedAgainst(tempList.get(i + 1))) {
  10. mPairingsRound.add(new Pairing(tempList.get(i), tempList
  11. .get(i + 1)));
  12. tempList.remove(i);
  13. tempList.remove(i + 1);
  14. } else {
  15. for (int j = i + 2; j <= tempList.size() - 1; j++) {
  16. if (!tempList.get(i)
  17. .getPlayerPlayedAgainst(tempList.get(j))) {
  18. mPairingsRound.add(new Pairing(tempList.get(i),
  19. tempList.get(i + 1)));
  20. tempList.remove(i);
  21. tempList.remove(i + 1);
  22. j = tempList.size() + 1;
  23.  
  24. }
  25. }
  26. }
  27.  
  28. }
  29.  
  30. return mPairingsRound;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement