/*
(non-Javadoc)

@see ws.sib.objectManager.List#listIterator()
321051
public ListIterator listIterator()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "listIterator");

        ListIterator listIterator = subList(null, null).listIterator();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "listIterator",
                       new Object[] { listIterator });
        return listIterator;
    }
1320103
public ListIterator<E> listIterator() {
        Object[] snapshot = elements;
        return new CowIterator<E>(snapshot, 0, snapshot.length);
    }
1121970
public ListIterator listIterator(long index,
                                     Transaction transaction)
                    throws ObjectManagerException
    {

        if (index < 0)
            throw new IndexOutOfBoundsException("Index: " + index);

        ListIterator listIterator = listIterator();
        try {
            for (long i = 0; i < index; i++)
                listIterator.next(transaction);
        } catch (java.util.NoSuchElementException exception) {
            // No FFDC code needed.
            throw new IndexOutOfBoundsException("Index: " + index);
        } // try.
        return listIterator;
    }
239800
public static <T> Iterator<T> filteringIterator(
        Iterator<? extends T> iterator, 
        Predicate<? super T> predicate)
    {
        Objects.requireNonNull(iterator, "The iterator is null");
        Objects.requireNonNull(predicate, "The predicate is null");
        return new FilteringIterator<T>(iterator, predicate);
    }
134337
@Override
  public Iterator<Page<T>> iterator() {

    return new Iterator<Page<T>>() {

      int currentIndex = 0;
      int currentPageNumber = 1;
      int pageSize = getPageSize();

      @Override
      public boolean hasNext() {
        return this.currentIndex < getList().size();
      }

      @Override
      public Page<T> next() {

        Assert.isTrue(hasNext(), new NoSuchElementException("No more pages"));

        Page<T> page = SimplePage.of(SimplePageable.this, this.currentPageNumber);

        this.currentIndex += this.pageSize;
        this.currentPageNumber++;

        return page;
      }
    };
  }
1011771
public static Iterator iterator(final ListModel self) {
        return new Iterator() {
            private int index = 0;

            public boolean hasNext() {
                return index < self.getSize();
            }

            public Object next() {
                return self.getElementAt(index++);
            }

            public void remove() {
                throw new UnsupportedOperationException("LisModel is immutable.");
            }
        };
    }
1189553
@Override
  public Iterator<Entry<K,V>> iterator() {
    checkClosed();
    final Iterator<K> _keyIterator = cache.keys().iterator();
    return new Iterator<Entry<K, V>>() {

      CacheEntry<K, V> entry;

      @Override
      public boolean hasNext() {
        while(_keyIterator.hasNext()) {
          entry = cache.getEntry(_keyIterator.next());
          if (entry.getException() == null) {
            return true;
          }
        }
        entry = null;
        return false;
      }

      @Override
      public Entry<K, V> next() {
        if (entry == null && !hasNext()) {
          throw new NoSuchElementException();
        }
        return new Entry<K, V>() {
          @Override
          public K getKey() {
            return entry.getKey();
          }

          @Override
          public V getValue() {
            return entry.getValue();
          }

          @SuppressWarnings("unchecked")
          @Override
          public <T> T unwrap(Class<T> _class) {
            if (CacheEntry.class.equals(_class)) {
              return (T) entry;
            }
            return null;
          }
        };
      }

      @Override
      public void remove() {
        if (entry == null) {
          throw new IllegalStateException("hasNext() / next() not called or end of iteration reached");
        }
        cache.remove(entry.getKey());
      }
    };
  }
598531
public List list() {
        final Iterator iter = nodeIterator();
        final List result = new LinkedList();
        while (iter.hasNext()) {
            result.add(new NodeChild((Node) iter.next(), this.parent, this.namespacePrefix, this.namespaceTagHints));
        }
        return result;
    }
132310
public static <T> Iterator<T> iteratorOverIterators(
        Iterator<? extends T> iterator0, Iterator<? extends T> iterator1)
    {
        Objects.requireNonNull(iterator0, "The iterator0 is null");
        Objects.requireNonNull(iterator1, "The iterator1 is null");
        List<Iterator<? extends T>> iterators = 
            new ArrayList<Iterator<? extends T>>(2);
        iterators.add(iterator0);
        iterators.add(iterator1);
        return Iterators.iteratorOverIterators(iterators.iterator());
    }
741706
void addIterator(final DataStreamingEventIterator<E> iterator) {
        checkLocked();
        if (iterator == null) {
            throw new NullPointerException("Iterator must not be null");
        }
        iteratorChain.add(iterator);
    }
1200442
@SequentialOnly
    public BiIterator<K, V> iterator() {
        final ObjIterator<Entry<K, V>> iter = s.iterator();

        final BooleanSupplier hasNext = new BooleanSupplier() {
            @Override
            public boolean getAsBoolean() {
                return iter.hasNext();
            }
        };

        final Consumer<Pair<K, V>> output = new Consumer<Pair<K, V>>() {
            private Entry<K, V> entry = null;

            @Override
            public void accept(Pair<K, V> t) {
                entry = iter.next();
                t.set(entry.getKey(), entry.getValue());
            }
        };

        return BiIterator.generate(hasNext, output);
    }
64605
@Override
	public final MutableObjectIterator<T> getIterator() {
		final SingleSegmentInputView startIn = new SingleSegmentInputView(this.recordsPerSegment * this.recordSize);
		startIn.set(this.sortBuffer.get(0), 0);
		
		return new MutableObjectIterator<T>() {
			
			private final SingleSegmentInputView in = startIn;
			private final TypeComparator<T> comp = comparator;
			
			private final int numTotal = size();
			private final int numPerSegment = recordsPerSegment;
			
			private int currentTotal = 0;
			private int currentInSegment = 0;
			private int currentSegmentIndex = 0;

			@Override
			public T next(T reuse) {
				if (this.currentTotal < this.numTotal) {
					
					if (this.currentInSegment >= this.numPerSegment) {
						this.currentInSegment = 0;
						this.currentSegmentIndex++;
						this.in.set(sortBuffer.get(this.currentSegmentIndex), 0);
					}
					
					this.currentTotal++;
					this.currentInSegment++;
					
					try {
						return this.comp.readWithKeyDenormalization(reuse, this.in);
					}
					catch (IOException ioe) {
						throw new RuntimeException(ioe);
					}
				}
				else {
					return null;
				}
			}

			@Override
			public T next() {
				if (this.currentTotal < this.numTotal) {

					if (this.currentInSegment >= this.numPerSegment) {
						this.currentInSegment = 0;
						this.currentSegmentIndex++;
						this.in.set(sortBuffer.get(this.currentSegmentIndex), 0);
					}

					this.currentTotal++;
					this.currentInSegment++;

					try {
						return this.comp.readWithKeyDenormalization(serializer.createInstance(), this.in);
					}
					catch (IOException ioe) {
						throw new RuntimeException(ioe);
					}
				}
				else {
					return null;
				}
			}
		};
	}
8640
public Iterator<Runnable> buildIterator() {
		return new Iterator<Runnable>() {
			@Override
			public boolean hasNext() {
				return false;
			}

			@Override
			public Runnable next() {
				return null;
			}

			@Override
			public void remove() {
			}
		};
	}
442382
public Iterator<ISO9660Directory> unsortedIterator() {
        if (unsortedIterator == null) {
            unsortedIterator = new ISO9660DirectoryIterator(this, false);
        }
        unsortedIterator.reset();
        return unsortedIterator;
	}
1316167
public static <T> List<T> asList(final Iterator<T> iterator)
   {
      List<T> result = new ArrayList<T>();
      while (iterator.hasNext())
      {
         T t = iterator.next();
         result.add(t);
      }
      return result;
   }
626951
public SIMPIterator getTopicNameIterator()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getTopicNameIterator");
    //if the stream is flushed then we have not subscribed
    //to any topics, so we return an empty list
    List topicList = null;
    if(_anycastInputHandler.getAIStream()!=null)
    {
      String[] topics =
            _anycastInputHandler.getRCD().getConsumerDispatcherState().getTopics();
       topicList = Arrays.asList(topics);
    }
    else
    {
      //we are flushed, so we are not currently subscribing for any
      //topics
      topicList = new LinkedList(); //create an empty collection
    }
    
    BasicSIMPIterator iterator = new BasicSIMPIterator(topicList.iterator());
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getTopicNameIterator", iterator);
    return iterator;                                   
  }
217632
public static <E> List<E> all(Iterator<E> iterator) {
        final Function<Iterator<E>, ArrayList<E>> consumer = new ConsumeIntoCollection<>(new ArrayListFactory<E>());
        return consumer.apply(iterator);
    }