Hi there,
GWT doesn't emulate the Collections.shuffle method (I think mainly because it
doesn't emulate Java.util.Random). You could write it fairly easily like this:
import com.google.gwt.user.client.Random;
// ... class declaration etc.
private void swap(List<?> list, int idx1, int idx2) {
Object o1 = list.get(idx1);
list.set(idx1, list.get(idx2));
list.set(idx, o1);
}
public void shuffle(List<?> objects) {
for(int i = objects.size; i > 1; i--) {
swap(list, i - 1, Random.nextInt(i));
}
}
For more info on what standard JRE methods /are/ implemented in GWT, take a look
at the docs here:
http://code.google.com/docreader/#p(google-web-toolkit-doc-1-5)s(google-web-toolkit-doc-1-5)t(RefJreEmulation)
Hope that helps
private void swap(List<?> list, int idx1, int idx2) {
Object o1 = list.get(idx1);
list.set(idx1, list.get(idx2));
list.set(idx2, o1);
}
While the shuffle method should look like what you had (objects instead of list).
Cheers.