- function Iterator(Object){
- this.Object=Object;
- this.count=0;
- }
- Iterator.prototype = {
- hasNext: function(){
- if(this.count < this.Object.length) return true;
- return false;
- },
- next: function(){
- if (this.hasNext())return this.Object[this.count++];
- return null;
- },
- remove: function(){
- try {
- this.Object[this.count]=null;
- }catch(e){
- return "UnsupportedOperationException";
- }
- }
- }
- /** utilisation */
- s=new Array('Samedi','Dimanche','Lundi','Mardi','Mercredi');
- it1=new Iterator(s);
- while(it1.hasNext()){
- alert(it1.next());
- }
- q=new Array("hello",'c',5212,4,"ok",s);
- it2=new Iterator(q);
-
- while(it2.hasNext()){
- alert(it2.next());
- }
function Iterator(Object){
this.Object=Object;
this.count=0;
}
Iterator.prototype = {
hasNext: function(){
if(this.count < this.Object.length) return true;
return false;
},
next: function(){
if (this.hasNext())return this.Object[this.count++];
return null;
},
remove: function(){
try {
this.Object[this.count]=null;
}catch(e){
return "UnsupportedOperationException";
}
}
}
/** utilisation */
s=new Array('Samedi','Dimanche','Lundi','Mardi','Mercredi');
it1=new Iterator(s);
while(it1.hasNext()){
alert(it1.next());
}
q=new Array("hello",'c',5212,4,"ok",s);
it2=new Iterator(q);
while(it2.hasNext()){
alert(it2.next());
}