Here is a model I am working on, where I am trying to create a list of agents from a population that meets the criteria.
traceln(filter( main.facilities, p -> p.WasteAvlty == 1 ));
The returned list is as follows,
But I want a list with the index number of the agent, and not the name of the agent. As my objective, is to create a list of agent index that meet the criteria.
The returned list should be like {0,1,2,3} and so on.
ArrayList <Integer> theList=new ArrayList();
List <Facility> facilities=filter( main.facilities, p -> p.WasteAvlty == 1 );
for(Facility f : facilities){
theList.add(f.getIndex());
}
Or
List <Facility> facilities=filter( main.facilities, p -> p.WasteAvlty == 1 );
int [] theList=new int[facilities.size()];
int i=0;
for(Facility f : facilities){
theList[i]=f.getIndex();
i++;
}