jsp - finding missing id's in java list -
im trying create table shows wich id can pick object (employee) adding database. options lastly one+1 , of "free" id spots got free deleting object.
im trying create list of missing ids , dosent work me. made jsp , shows id's on way top id.
int lastid =tablelist.get(aadmin.getallemps().size()-1).getid(); list <integer> idlist=new arraylist<integer>(); int counter=0; itr= tablelist.iterator(); int i=0; while(itr.hasnext()){ employee tempemp=itr.next(); int id=tempemp.getid(); if(id!=i+counter){ for(int j=0 ; j<id-(i+counter); i++) idlist.add(i+counter+j); counter=counter+(id-(i+counter)); } i++;} iterator<integer> iditr=idlist.iterator(); while(iditr.hasnext()) { integer tempint= iditr.next(); %> <tr> <td> <%=tempint %><input type="radio" name="id" value="<%=tempint%>"> </td> </tr> <%}%> </table> <br>
any ideas ?
let's assume have list of integers (ids used) , expect have set<integer>
ids free.
define max variable.
go through list of existing ids.
if current id list bigger max
add together numbers between old max
, new max
, set max
new value set. if it's smaller max
remove set.
java jsp
No comments:
Post a Comment