org.apache.ignite.internal.util.lang

## Interface GridCloseableIterator<T>

All Superinterfaces:
  AutoCloseable, GridIterator<T>, GridSerializableIterator<T>, IgniteSpiCloseableIterator<T>, Iterable<T>, Iterator<T>, Serializable

All Known Subinterfaces:
  CacheWeakQueryIteratorsHolder.WeakReferenceCloseableIterator<T>

All Known Implementing Classes:
  CacheWeakQueryIteratorsHolder.WeakQueryCloseableIterator, GridCloseableIteratorAdapter, GridCloseableIteratorAdapterEx, GridEmptyCloseableIterator, GridSpiCloseableIteratorWrapper

    public interface GridCloseableIterator<T>
    extends GridIterator<T>, IgniteSpiCloseableIterator<T>, AutoCloseable

Defines "rich" closeable iterator interface that is also acts like lambda function and iterable.

Any instance of this interface should be closed when it's no longer needed.

Here is the common use of closable iterator.

     GridCloseableIterator<T> iter = getIterator();

     try {
         while(iter.hasNext()) {
             T next = iter.next();
             ...
             ...
         }
     }
     finally {
         iter.close();
     }

### Method Summary

Methods
`void` `close()` Closes the iterator and frees all the resources held by the iterator.
`boolean` `isClosed()` Checks if iterator has been closed.

### Methods inherited from interface org.apache.ignite.internal.util.lang.GridIterator

`hasNextX, nextX, removeX`

### Methods inherited from interface java.lang.Iterable

`iterator`

### Methods inherited from interface java.util.Iterator

`hasNext, next, remove`

### Method Detail

#### close

    void close()
               throws IgniteCheckedException

Closes the iterator and frees all the resources held by the iterator. Iterator can not be used any more after calling this method.

The method is invoked automatically on objects managed by the `try-with-resources` statement.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `IgniteSpiCloseableIterator<T>`
Throws:
  `IgniteCheckedException` - In case of error.

#### isClosed

    boolean isClosed()

Checks if iterator has been closed.

Returns:
  `True` if iterator has been closed.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.6.0
Release Date | : May 18 2016