src/jdk/nashorn/internal/runtime/arrays/MapIterator.java

Print this page




  49     }
  50 
  51     @Override
  52     public int getLength() {
  53         return (int) length;
  54     }
  55 
  56     @Override
  57     public boolean hasNext() {
  58         if (length == 0L) {
  59             return false; //return empty string if toUint32(length) == 0
  60         }
  61 
  62         while (indexInArray()) {
  63             if (obj.has(index) || includeUndefined) {
  64                 break;
  65             }
  66             bumpIndex();
  67         }
  68 
  69         // special case - balk at iterating to infinity or MAX_UINT
  70         return (length != JSType.MAX_UINT) && indexInArray();
  71     }
  72 
  73     @Override
  74     public Object next() {
  75         if (indexInArray()) {
  76             return obj.get(bumpIndex());
  77         }
  78 
  79         throw new NoSuchElementException();
  80     }
  81 }


  49     }
  50 
  51     @Override
  52     public int getLength() {
  53         return (int) length;
  54     }
  55 
  56     @Override
  57     public boolean hasNext() {
  58         if (length == 0L) {
  59             return false; //return empty string if toUint32(length) == 0
  60         }
  61 
  62         while (indexInArray()) {
  63             if (obj.has(index) || includeUndefined) {
  64                 break;
  65             }
  66             bumpIndex();
  67         }
  68 
  69         return indexInArray();

  70     }
  71 
  72     @Override
  73     public Object next() {
  74         if (indexInArray()) {
  75             return obj.get(bumpIndex());
  76         }
  77 
  78         throw new NoSuchElementException();
  79     }
  80 }