From: <the...@us...> - 2003-12-16 10:53:38
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/util In directory sc8-pr-cvs1:/tmp/cvs-serv334 Modified Files: HostMap.java Log Message: implemented OnlineIteratorProvider Index: HostMap.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/util/HostMap.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HostMap.java 26 Nov 2003 20:26:53 -0000 1.1 --- HostMap.java 16 Dec 2003 10:53:31 -0000 1.2 *************** *** 25,28 **** --- 25,29 ---- import java.util.HashMap; import java.util.Iterator; + import java.util.Map; import junk.util.NameOnline; *************** *** 30,40 **** /** Hashmap Wrapper to provide additional functionality ! * @author flow */ ! public class HostMap extends HashMap { /** returns an Iterator over the online ip addresses * @return an Iterator over the online ip addresses */ ! public Iterator onlineIterator() { return new OnlineIterator(this); } --- 31,41 ---- /** Hashmap Wrapper to provide additional functionality ! * @author Marcus Proest (theevilflow at users dot sf dot net) */ ! public class HostMap extends HashMap implements OnlineIteratorProvider, Map { /** returns an Iterator over the online ip addresses * @return an Iterator over the online ip addresses */ ! public Iterator getOnlineIterator() { return new OnlineIterator(this); } *************** *** 70,76 **** if (((NameOnline) this.h.get(ip)).getOnline() .equals(Boolean.TRUE)) { ! return true; } this.ip = (String) this.keys.next(); } --- 71,79 ---- if (((NameOnline) this.h.get(ip)).getOnline() .equals(Boolean.TRUE)) { ! return true; //return true if we get an online ip } + + //if it was false (or null), try the next one this.ip = (String) this.keys.next(); } *************** *** 87,94 **** if (((NameOnline) this.h.get(ip)).getOnline() .equals(Boolean.TRUE)) { ! String temp = this.ip; ! this.ip = (String) keys.next(); ! return temp; } --- 90,97 ---- if (((NameOnline) this.h.get(ip)).getOnline() .equals(Boolean.TRUE)) { ! String temp = this.ip; //save current value ! this.ip = (String) keys.next(); //forward iterator ! return temp; //return value } *************** *** 96,100 **** } ! //if there is no next key, hasNext should return false throw new java.util.NoSuchElementException(); } --- 99,103 ---- } ! //if there is no next key, hasNext would return false throw new java.util.NoSuchElementException(); } |