java - ArrayList get all the elements -
in function, once if statement becomes true, returns value , "kicks" me out of function. i'm trying rest of elements of arraylist, know ones i'm not going access it. question is, how can rest of elements array?
for(node a:state.children) { state.value = math.max(state.value,min_value(a, alpha, beta)); alpha = math.max(alpha,state.value); if(beta <=alpha) { system.out.println("the elements going skipped are: " + a.label); return state.value; } }
how can make copy of last elements of array not going used because of return statement
have arraylist hold unskipped values. that, add else block existing if block. in else block add element temp arraylist. iterate through temp arraylist unskipped values.
arraylist<node> templist = new arraylist<node>(); for(node a:state.children) { state.value = math.max(state.value,min_value(a, alpha, beta)); alpha = math.max(alpha,state.value); if(beta <=alpha) { system.out.println("the elements going skipped are: " + a.label); } else { templist.add(a); } }
Comments
Post a Comment