import java.util.List;
import java.util.Iterator;

public class RoundRobin implements Algorithm {

	public List<UR> allocateUR(List<User> users, List<UR> urs) {
		UR ur;
		User user;
		int cpt = 0;
		Iterator<User> it = users.iterator();
		Iterator<UR> it_ur = urs.iterator();
		while(it.hasNext() && it_ur.hasNext()){
			do {
				// There is an user 
				if(!it.hasNext()) {
					it = users.iterator();
					cpt++;
				}
				user = it.next();
			} while(user.getCurrentPacket() == null && cpt == 1);

			if(user.getCurrentPacket() != null) {
				ur = it_ur.next();
				ur.affectURToUser(user);
				user.checkPacket();
			}
		}

		return urs;
	}
}

@@ -272,16 +272,19 @@
 or();%0A%09%09
+// 
 while(it
@@ -321,16 +321,19 @@
 %7B%0A%09%09
+// 
 %09do %7B%0A%09%09
 %09%09//
@@ -328,16 +328,19 @@
 %09do %7B%0A%09%09
+// 
 %09%09// The
@@ -356,16 +356,19 @@
 user %0A%09%09
+// 
 %09%09if(!it
@@ -383,16 +383,19 @@
 ()) %7B%0A%09%09
+// 
 %09%09%09it = 
@@ -414,16 +414,19 @@
 or();%0A%09%09
+// 
 %09%09%09cpt++
@@ -429,22 +429,28 @@
 pt++;%0A%09%09
+// 
 %09%09%7D%0A%09%09
+// 
 %09%09user =
@@ -463,16 +463,19 @@
 xt();%0A%09%09
+// 
 %09%7D while
@@ -524,16 +524,19 @@
  1);%0A%0A%09%09
+// 
 %09if(user
@@ -568,16 +568,19 @@
 ll) %7B%0A%09%09
+// 
 %09%09ur = i
@@ -594,16 +594,19 @@
 xt();%0A%09%09
+// 
 %09%09ur.aff
@@ -626,16 +626,19 @@
 ser);%0A%09%09
+// 
 %09%09user.c
@@ -653,18 +653,537 @@
 et();%0A%09%09
-%09%7D
+// %09%7D%0A%09%09// %7D%0A%0A%09%09boolean found = false;%0A%0A%09%09while(it_ur.hasNext()) %7B%0A%09%09%09cpt = 0;%0A%09%09%09ur = it_ur.next();%0A%09%09%09user = null;%0A%09%09%09%0A%09%09%09found = false;%0A%0A%09%09%09while(!found && cpt %3C 2) %7B%0A%09%09%09%09if(it.hasNext()) %7B%0A%09%09%09%09%09user = it.next();%0A%09%09%09%09%09if(user.getCurrentPacket() != null)%7B%0A%09%09%09%09%09%09found = true;%0A%09%09%09%09%09%7D%0A%09%09%09%09%09else %7B%0A%09%09%09%09%09%09user = null;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%09else %7B%0A%09%09%09%09%09cpt ++;%0A%09%09%09%09%09it = users.iterator();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%0A%09%09%09if(user != null) %7B%0A%09%09%09%09ur.affectURToUser(user);%0A%09%09%09%09user.checkPacket();%0A%09%09%09%7D%0A%0A%09%09%09if(!it.hasNext())%0A%09%09%09%09it = users.iterator();
 %0A%09%09%7D%0A%0A%09%09

Improve RR algorithm