IdRandomizer.java

Go to the documentation of this file.
00001 package ns2;
00002 
00003 import java.util.LinkedList;
00004 import java.util.List;
00005 import java.util.Random;
00006 
00013 public class IdRandomizer {
00019     public static void randomize(List<String> wantedVehicle, List<String> vehicleNewId, long seed) {
00020         // set of new ids = {0, 1, ..., N-1}
00021         int N = wantedVehicle.size();
00022         List<String> tmpId = new LinkedList<String>();
00023         for (int i=0; i<N; i++) {
00024             tmpId.add("" + i);
00025         }
00026         Random rnd = new Random(seed);
00027         for (int i=0; i<N; i++) {
00028             int num = rnd.nextInt(tmpId.size());
00029             String val = tmpId.remove(num);
00030             vehicleNewId.add(val);
00031         }
00032     }
00033 }

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6