All pastes #995322 Raw Edit

Someone

public text v1 · immutable
#995322 ·published 2008-04-24 01:17 UTC
rendered paste body
    /**
    * This method is supposed to generate dependecies for som jobs
    * example:
    * job 1 : null
    * job 2 : 1
    * job 3 : 1
    * job 4 : 1,2,3
    */
    private List<Integer>[] makeDependencies(int jobNum){
        Random objRandom=new Random();
        Timestamp time= new Timestamp(123456789);//this is to set the seed
        List<Integer>[] arreListInt= new ArrayList[jobNum];//this will store the list of jobs with their dependencies
        List<Integer> objListInt= new ArrayList(jobNum);//this is a list that will have all the jobs {0,1,2,3,4,5,6,7,...}
        // I fill the list with 0,1,2,.....
        for(int i=0;i<=jobNum;i++){
            objListInt.add(i);
        }
        for(int i=1;i<=jobNum;i++){
            List<Integer> objListIntAux=objListInt.subList(0, i);//get the sublist of possible dependencies
            int dependencies=objRandom.nextInt(i+1);//how many dependencies will this job have
            Collections.shuffle(objListIntAux);//shuffle the list of possible dependencies, so the dependecies wont be in order
            arreListInt[i]=new ArrayList<Integer>();//I don't know if this step is necessary
            arreListInt[i]=objListIntAux.subList(0, dependencies+1);//this will get a sublist of dependecies, but HERE is the problem, I get and error like this Exception in thread "main" java.lang.ArrayStoreException: java.util.RandomAccessSubList
        }
        return arreListInt;
        }